Install oh-my-zsh
当前文档有中文版本:点击这里切换到中文.
Foreword
Commonly used shell interpreters are sh
and bash
, but there are, of course, others such as ksh
, csh
, and zsh
.
The tool we are about to install, Oh My Zsh, is an extension based on zsh
. Similarly, there is Oh My Posh for Windows, both of which are extension toolkits for the original command line. They provide many rich features and offer various command-line styles, making our terminal more visually appealing.
GitHub:oh my zsh
Prepare
Before installing Oh My Zsh, we need to install zsh and set it as our default shell.
PS: In some Linux distributions (such as Kali) and macOS, zsh is the default shell interpreter, so no additional setup is required in those cases.
Install zsh
View all available shell interpreters and the current shell interpreter.
cat /etc/shells |
sudo apt-get install zsh -y |
sudo yum install zsh -y |
install oh my zsh
There are several ways to install Oh My Zsh. Typically, you can use the installation script provided by the official source or manually clone the repository and configure it yourself. Regardless of the method, the git command is required. If you don’t have git installed, you’ll need to install it.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
Edit .zshrc
cat > ~/.zshrc <<"EOF" |
After executing the above commands, you’ll notice that the current command line is using Oh My Zsh. You can also configure the ~/.zshrc
file to set up more plugins, and you can download non-official plugins into the ~/.oh-my-zsh/custom/plugins
directory for use.
Install Plugins
Two recommended plugins are:
- zsh-syntax-highlighting: Provides syntax highlighting for commands.
- zsh-autosuggestions: Suggests previously typed commands based on history.
Here’s how to install these two plugins:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting |
Edit the ~/.zshrc file to activate these
plugins=( |
At this point, the installation is complete. You can try out the new command line now.