Ubuntu18.04 builds a god-level terminal based on Oh-my-zsh
One, oh-my-zsh
Zsh is a powerful terminal. Compared with the original bash, it can achieve syntax highlighting, automatic completion and other functions. In addition, the rich skin makes it a pleasant working mood. Because it is cumbersome to configure zsh directly, it is recommended to use the open source project oh-my-zsh on github for one installation
1. Install zsh
sudo apt-get install zsh
2. Download and run oh-my-zsh
Two installation methods are recommended on the homepage of oh-my-zsh , and readers can download and install them by themselves.
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
##或者
$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
The following icon indicates that the installation is successful.
This time, it will usually fail because of the external network, which causes the network to be unreachable. If you fail to run the above command, you can also install it in the following way.
# 下载文件
git clone https://github.com/ohmyzsh/ohmyzsh
# 若因为网速问题,无法抵达可以用我搬运至码云的链接下载
git clone https://gitee.com/jasonli0012/ohmyzsh
# 赋予安装脚本可执行权限
cd ohmyzsh/tools
chmod +x install.sh
# 安装
./install.sh
3. Set as the default terminal
Enter the following command in the terminal to achieve the configuration:, chsh -s /bin/zsh
then press Ctrl+Alt+T on the keyboard to open a new command line and you will find that you have entered zsh.
4. Configure the skin
Enter the following command on the command line to enter to modify the configuration file:
# nano编辑器进行编辑
sudo nano ~/.zshrc
# gedit编辑器进行编辑
sudo gedit ~/.zshrc
Here we choose nano editor for editing. Find the content in the text ZSH-THEME, modify the subsequent value to the selected theme and click Ctrl+O on the keyboard to save, and Ctrl+X to exit.
Here the host chooses the agnoster theme for configuration. A large number of themes will be automatically installed when zsh is installed, and ls ~/.oh-my-zsh/themes
you can view it by entering the command . In addition, there are a large number of available topics and their introductions on github .
5. Install the font library
If you choose the same theme agnoster as the original poster , you need to download an additional font library to prevent it from garbled.
sudo apt-get install fonts-powerline
After installation is complete, click on the upper left corner of the command line editing tab under Preferences , font command line changes for the corresponding font (suffix usually -powerline after the font)
6. Install the plugin
Zsh has a strong development community, which makes it have a large number of plug-ins. The host here only recommends a few plug-ins for personal use and demonstrates how to configure the plug-ins with one of them.
- Syntax highlighting plugin (zsh-syntax-highlighting): https://github.com/zsh-users/zsh-syntax-highlighting
- Automatic jump plugin (zsh-autojump): https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/autojump
Like the skin, zsh has some plug-ins installed by default, which can be queried in the terminal. In addition, there are also a large number of plugins waiting to be discovered on github .
ls ~/.oh-my-zsh/plugins
After selecting your favorite plug-in, you need to download it first, then use the nano editor to edit the .zshrc file, find the content plugins= down , and modify the content afterwards.
Take the syntax highlighting plugin as an example.
cd ~/.oh-my-zsh/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# nano编辑器进行编辑
sudo nano ~/.zshrc
# gedit编辑器进行编辑
sudo gedit ~/.zshrc
zsh git plug-in is enabled by default, each plug-in name need to use a space separated. After the modification is completed, press Ctrl+O to save, and press Ctrl+X to exit. Then, enter the following command on the command line to make the configuration effective.
source ~/.zshrc
7. Tips
The main reason why the original poster loves zsh is that it can help complete commands. When you enter a command or find a folder, click the Tab key to help you automatically complete the format.
When searching for files, there are multiple files with the same beginning in the path, click the Tab key to list all the files with the same beginning as candidates, and then click the Tab key to select the candidates in sequence.
2. Beautify the terminal interface
Enter Ctrl+Alt+T on the keyboard to open the terminal, and then click the edit menu bar at the upper left of the interface . Select the preferences to configure.
The landlord configuration parameters are as follows:
The final effect is as follows: