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.

Insert picture description here

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/zshthen press Ctrl+Alt+T on the keyboard to open a new command line and you will find that you have entered zsh.

Insert picture description here

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.
Insert picture description here
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/themesyou can view it by entering the command . In addition, there are a large number of available topics and their introductions on github .
Insert picture description here
Insert picture description here

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)
Insert picture description here

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.

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

Insert picture description here

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.

Insert picture description here
The landlord configuration parameters are as follows:

Insert picture description here
Insert picture description here

The final effect is as follows:

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_45929038/article/details/114127431