One, we must first understand zsh
Shell the Z- ( Zsh ) is used as an interactive login shell and scripting of the command interpreter . Zsh has made a lot of improvements to the Bourne shell and added some features of Bash , ksh and tcsh .
Features include:
- Programmable command line completion function that can help users enter commonly used command options and parameters , with built-in support for hundreds of commands
- Command history can be shared with any Shell
- File expansion can be used to match files without running external programs (such as find )
- Improve variable / array handling
- Edit multiple lines of commands in a single buffer
- Spell Check
- Multiple compatibility modes (for example, Zsh can
/bin/sh
pretend to be a Bourne shell when it is running ) - Programmable command line interface , including the function of displaying the prompt line information on the right side of the screen and automatically hiding it when a long command is entered
- Loadable modules can provide additional support: complete transmission control protocol , Unix domain socket control, FTP client and extended mathematical functions.
- The built-in
where
command, which iswhich
similar to the command, but displays$PATH
all the positions specified in the command instead of only the position of the used command. - Directory name. This feature allows the user to set shortcuts (such as
~mydir
with~
and~user
work similar).
2. Linux system installation:
Take the centos7 system as an example here
View the shell currently used by the system:
echo $SHELL
Check whether the system has zsh installed:
cat /etc/shells
Centos7 is not installed by default, if not installed, install zsh first
yum install zsh
Set zsh as the default:
chsh -s /bin/zsh
To install oh-my-zsh, first make sure you have installed git:
(1) Automatic installation:
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
Successful installation
(2) Manual installation:
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
Need to copy
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
At this point, oh-my-zsh is installed
3. Command line highlighting (zsh-syntax-highlighting)
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
edit:
vim ~/.zshrc
Add the plugin name in the configuration
plugins=( [plugins...] zsh-syntax-highlighting)
After the modification is completed, you need to run:
source ~/.zshrc
Make changes take effect
Four, historical command records (zsh-autosuggestions)
Next install the code prompt zsh-autosuggestions:
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
or
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
edit:
vim ~/.zshrc
Add the plug-in name in the configuration:
plugins=( [plugins...]
zsh-autosuggestions)
After the modification is completed, you need to run:
source ~/.zshrc
Make changes take effect
If the prompt color is white, not gray, you can modify the prompt color:
export TERM=xterm-256color
Or or add it to .zshrc:
echo "export TERM=xterm-256color" >> ~/.zshrc
Then execute again:
source ~/.zshrc
After modifying the ~/.zshrc operation, you must source it to make the modification effective