Installation and Setup of Zsh and Oh-My-Zsh

zsh is a powerful terminal under linux, but the default terminal of ubuntu is bash. ohmyzsh is an extension tool set based on zsh, which provides rich extension functions.

Install Zsh

sudo apt-get install zsh

Check which terminals have been installed in the current system, if there is /bin/zshthis default terminal, we will go to the next step

cat /etc/shells

Here we installed zsh, but also need to set him as the default terminal

chsh -s /bin/zsh

But although we have successfully set up, our terminal is still bash, and we can use the command to view the current terminal

echo $SHELL

Here, my system needs to be restarted to modify the default terminal.

Install Oh-My-Zsh

Oh-My-Zsh is installed by running one of the following commands in Terminal. You can install it via command line using curl, wget or other similar tools.

method Order
wget sh -c “$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”
curl sh -c “$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”
fetch sh -c “$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”

Here we use some download tools, whichever one is used, all three are fine. After the installation is complete, you can reopen a terminal. That is ZSH with Oh-My-Zsh installed.

Using Oh-My-Zsh

plug-in

Once you find a plugin (or a few) that you want to use with Oh My Zsh, you need to .zshrcenable them in the file. You will $HOMEfind the zshrc file in the directory. Open it with your favorite text editor and you'll see a place listing all the plugins you want to load.

vim ~/.zshrc

The plugin settings are as follows

# 默认初始安装只会启用一个git插件,插件由空格、制表符、新行分隔。不要在它们之间使用逗号,否则会中断。
plugins=(git)

Oh-My-Zsh comes with many plugins, we can find the default plugins at this address (https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins).

Here are two more useful plug-in recommendations

zsh-autosuggestions

This is an autocomplete plugin

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

zsh-syntax-highlighting

This is a display highlighting plugin

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

configuration file

This is how the above two plug-ins are written into the configuration file. We can add what we want later by ourselves.

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

theme

The built-in theme can be viewed at this URL (https://github.com/ohmyzsh/ohmyzsh/wiki/Themes)

The configuration of the theme is also in .zshrcthe file

ZSH_THEME="robbyrussell"

I prefer this default theme, but you can look at the theme in the wiki, there are screenshots, just replace it with whichever you like.

to refresh

After installation, you need to refresh the configuration file to take effect

source ~/.zshrc

But restarting a terminal directly can also

Uninstall Oh-My-Zsh

uninstall_oh_my_zsh

Running this command will not only remove Oh-My-Zsh, but will also return your shell to the default and previous configuration of zsh or bash.

But it is said that this thing can not be deleted. . . .

Guess you like

Origin blog.csdn.net/weixin_43903639/article/details/131013622