Zsh: The Efficiency Powerhouse for Linux
For developers who use Linux regularly, the shell is one of the most frequently used programs. It acts as a bridge between developers and the Linux system, allowing us to perform complex operations with simple commands.
Bash is the default shell on Linux, while Zsh is a more user-friendly shell that is fully compatible with Bash. Using Zsh is as satisfying as scratching an itch, and it can greatly boost your efficiency when working with Linux.
Steps
1. Installing Zsh
On Debian-based Linux distributions, install Zsh with the following command; other Linux distributions are similar:
| |
2. Installing Oh My Zsh
The default Zsh configuration is a bit tedious, so a user named robbyrussell created a configuration framework Oh My Zsh on GitHub. It is by far the most popular Zsh configuration.
You can install it using either curl or wget. During installation, you will be asked whether to switch your default shell to zsh — enter y to accept:
Install with curl
- GitHub:
1sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"- Gitee (domestic mirror)
1sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"Install with wget
- GitHub:
1sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"- Gitee (domestic mirror)
1sh -c "$(wget -O- https://gitee.com/pocmon/mirrors/raw/master/tools/install.sh)"
3. Setting the Theme
Run the following command to open and edit the Oh My Zsh configuration file:
| |
The ZSH_THEME="robbyrussell" parameter controls the theme; change it to random to use a random theme.
Every time you open the terminal, you will see output like the following; note down any theme you like:
| |
4. Other Oh My Zsh Operations
- Uninstall:
| |
- Update:
| |
5. Zsh Quick Start
Use the following command to open the configuration file, find the plugins parameter, and enter the plugins you want to enable inside the parentheses, separated by spaces:
| |
After enabling the plugins, refresh the shell with the following command:
| |
Here is what these plugins do:
- git: No configuration needed; it is enabled by default. It lets you enter git commands using shorthand aliases. Use the following command to view all the aliases:
| |
Z: No configuration needed; it is enabled by default. It lets you quickly jump to directories you have visited before; just use
z directoryto jump there directly.zsh-syntax-highlighting: Highlights your command input — correct syntax is shown in green and syntax errors in red. You need to install it yourself; the install command is as follows:
| |
- zsh-autosuggestions: Finds prefix-matching entries from your command history; press the right arrow key ➡ to complete them quickly. It is especially handy. You need to install it yourself; the install command is as follows:
| |