Supercharge Linux Workflow: z Shortcut, Vim Setup, MySQL Prompt & System Info
This guide shows how to speed up Linux command‑line work by installing the z directory‑jump script, applying a feature‑rich Vim configuration, customizing MySQL prompts, accurately checking OS version, and using a more visual disk‑usage tool.
1. Quick directory jump with z
The z script records each directory you cd into and assigns a weight based on frequency and recency. When you type z <pattern>, it selects the highest‑weighted match and changes to that directory.
Installation steps:
Download the script from the official repository: https://github.com/rupa/z/blob/master/z.sh
Save it as ~/z.sh (or any location you prefer).
Add the line source ~/z.sh to the end of your ~/.bashrc (or ~/.zshrc if you use Zsh).
Reload the shell configuration with source ~/.bashrc (or start a new terminal).
After reloading, you can jump to a previously visited directory by typing, for example, z project. The script will change to the most relevant path that contains the word “project”.
2. Vim configuration for a richer coding experience
A ready‑made Vim configuration can provide code completion, fast file search, a directory tree, and language‑specific header completions for C and Python.
Typical setup procedure:
Download the configuration archive (the article supplies a zip/tar file).
Extract the archive into your home directory, which will create a .vim directory and a .vimrc file.
Open a new terminal or run source ~/.vimrc to apply the settings.
Optional: install the required plugins (e.g., vim-plug or Vundle) by running :PlugInstall inside Vim.
After these steps, Vim will show a file‑tree sidebar, enable omni‑completion for Python ( Ctrl‑X Ctrl‑O) and C header completion, and allow fuzzy file search with :Files (provided by the fzf plugin).
3. Adding a prompt to the MySQL client
To avoid confusion when working with multiple MySQL servers, you can customize the client prompt to show the current user, host, and database.
[mysql]
prompt="\u@\h : \d \r:\m:\s>"Place the above section in /etc/my.cnf for a system‑wide change or in ~/.my.cnf for a user‑specific change. Restart the MySQL client (or reconnect) and the prompt will display information such as root@db01 : testdb 12:34:56>, reducing the risk of executing commands on the wrong server.
4. Accurately checking the operating system version
Traditional files such as /etc/issue, /etc/redhat-release or /etc/issue.net can be edited or removed, making them unreliable. A more robust method is to query the kernel and distribution information directly.
Common commands that work on most Linux distributions:
# uname -a # kernel name, version and architecture
# cat /etc/os-release # standardized distribution metadata (NAME, VERSION, ID, etc.)
# lsb_release -a # if the <code>lsb-release</code> package is installedThese commands return accurate data even when the legacy files are missing or altered.
5. Visualizing disk usage
While fdisk and df provide raw partition and filesystem statistics, a tree‑like visual representation makes it easier to locate large directories.
A popular tool for this purpose is ncdu (NCurses Disk Usage). Install it with your package manager (e.g., yum install ncdu, apt-get install ncdu) and run:
# ncdu / # scans the entire filesystem and shows an interactive tree viewThe interface displays directories sorted by size, allowing you to drill down with arrow keys and delete unwanted files directly from the UI.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
