This article is transcoded by 简悦 SimpRead, original address zhuanlan.zhihu.com
1. Install oh my zsh
- What is zsh?
Zshis a powerful virtual terminal, serving as both a system virtual terminal and an interactive interpreter for a scripting language. - How to check if zsh is installed?
- Enter in the terminal:
zsh --version
- My output:
zsh 5.7.1 (x86_64-apple-darwin19.0)
This indicates that I have already installed zsh.
- oh my zsh
① Installation
You can install via two methods:curlorwget, with one command.
- curl installation
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- wget installation
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
② Simple configuration
Set a fixed theme
- In the terminal, enter:
open ~/.zshrc - Find
ZSH_THEME="robbyrussell", here the default themerobbyrussellis set. To change the theme, use this format:ZSH_THEME="theme_name" - Save the file and reopen the terminal
Set a random theme
- In the terminal, enter:
open ~/.zshrc - Set the theme as:
ZSH_THEME="random" - This way, each time you open the terminal, the theme is random.
- Example: next time you open the terminal, it will output a message like
[oh-my-zsh] Random theme 'xiong-chiamiov' loaded, where ‘xiong-chiamiov’ is the theme name. If you like this theme, you can set it in your .zshrc.
View theme names
oh my zsh comes with some default themes stored in the ~/.oh-my-zsh/themes directory. We can view these themes:
cd ~/.oh-my-zsh/themes && ls
③ Uninstall oh my zsh
uninstall_oh_my_zsh
④ Solution to accidentally disabling the automatic update prompt of oh my zsh
upgrade_oh_my_zsh
2. Install autojump
Plugin function: allows quick directory jumping. Just type j + directory name to go directly to the directory, no need to frequently use cd!
- Installation steps
- Enter in the terminal:
$ brew install autojump
- Output:

- According to the prompt, add the following in the
~/.zshrcfile:
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
- Use the
sourcecommand to update the configuration file:
source ~/.zshrc
- Now you can use the
jcommand to quickly jump to target directories based on yourcdhistory without repeatedly typingcd~
3. Install zsh-syntax-highlighting
Plugin function: this package provides syntax highlighting for the shell zsh. It highlights commands entered at the zsh prompt in the interactive terminal. This helps check commands before execution, especially for catching syntax errors.
Example: if the command you type does not exist, it shows as red; otherwise, it turns green.
- Documentation
- 《zsh-syntax-highlighting》
- Installation steps
- Enter in the terminal:
$ brew install zsh-syntax-highlighting
- Output:

Add to ~/.zshrc file:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
- Use the
sourcecommand to update the configuration file:
source ~/.zshrc
-
Install zsh-autosuggestion
Plugin function: provides command autosuggestions (grey part) while typing; press Tab key (→ ) to complete. -
Documentation:
- 《zsh-autosuggestions》
- Installation steps
- Enter in the terminal:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
- Add to the
~/.zshrcfile:
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
- Use the
sourcecommand to update the configuration file:
source ~/.zshrc