oh my zsh introduction
oh my zsh is an open source shell terminal command line tool based on zsh. It not only has many beautiful theme toolkits, but also has many useful plug-ins, which can greatly improve work efficiency after installation.
Install oh my zsh
# 下载安装包
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
# 备份原来的zsh配置
cp ~/.zshrc ~/.zshrc.orig
# 新建一个 zshrc 配置文件
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 修改默认的 zsh 为oh my zsh
chsh -s $(which zsh)
Configure theme
# 查看可用主题
ll ~/.oh-my-zsh/themes
# 修改主题
vim ~/.zshrc
Modify the ZSH_THEME configuration of the .zshrc file. For example, I changed it to "angoster":
After the theme is modified, you need to reopen the terminal or execute the following command to take effect:
source ~/.zshrc
Install plugin
oh my zsh has the git plug-in installed and configured by default. There are many plug-ins that can be configured directly in the ~/.oh_my_zsh/plugins directory. Just configure it in .zshrc.
Or you can download some plug-ins yourself, put them under ~/.oh-my-zsh/custom/plugins, and then configure them in the .zshrc file.
Here are only two commonly used plug-ins recommended:
- zsh-autosuggestions: It can be used to complete the command by pressing tab. It will also automatically prompt the previously entered command, and then you can press the "→" direction key to complete the command automatically.
- zsh-syntax-highlighting: You can highlight the shell command syntax, and the command error will be displayed in red
The following is just an example of installing zsh-autosuggestion:
# 进入目录 ~/.oh-my-zsh/custom/plugins
cd ~/.oh-my-zsh/custom/plugins
# 下载插件
git clone https://github.com/zsh-users/zsh-autosuggestions
# 配置插件
vim ~/.zshrc
Configure the plug-in name to plugins in the .zshrc file, and separate different plug-in names with spaces. After the configuration is completed, remember to execute "source ~/.zshrc" or reopen a terminal for the configuration to take effect.
Uninstall oh my zsh
uninstall_oh_my_zsh