Use Oh my zsh to beautify the Linux terminal (WSL - Ubuntu) (2)

This article continues the previous article, introducing the beautification of WSL in the Windows terminal, of course, that is the beautification of the Linux terminal. This time using Oh my posh's origin project, oh my zsh

Previous article: Beautify Windows terminal with Oh my posh (1)

Prepare

Bash is the default shell for most Linux terminals. Explain the difference between the terminal and the shell in a simple way. For example, the terminal is an IDE, and the shell is a compiler. The commands you enter in the terminal are finally handed over to the shell for execution.

I use WSL as the demo Linux system, the distribution is Ubuntu 20.04 LTS. WSL can be downloaded directly from the Microsoft store, and there are detailed tutorials on the Internet for the installation method. However, if necessary, I will publish a separate tutorial later.

In order to beautify, we need to replace the default Bash with Zsh. Most of Zsh's syntax matches Bash's.

check shell

Check the installed shells by typing:

$ cat /etc/shells 

Enter the following command to view the default shell (note capitalization):

$ echo $SHELL

shellNo Zsh, needs to be installed. If you have one, you can skip the installation step.

Install Zsh

ubuntu:

sudo apt-get install zsh

install zsh
After installation, don't rush to start zsh. The default configuration of zsh is very complicated, so we need to use Oh my zsh to configure zsh, which is to beautify the configuration.

Install Oh my zsh

Use the domestic gitee mirror to download the script:

wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh

insert image description here

After the script is downloaded, the privilege needs to be raised, and the executable privilege is increased by using the following code:

chmod +x install.sh

implement:

./install.sh

In this step, if you find that the download is very slow, you can open and install.shmodify the image (I use VS Code, because this is the only graphical text editor available under WSL, you can change it to vim):

code install.sh

Find the following section:
to modifyChange the middle two lines to:

REPO=${REPO:-mirrors/oh-my-zsh}
REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}

Save and execute again. You should see the following prompt:oh my zsh

beautify

change the default shell

Change the default shell to zsh:

$ chsh -s /bin/zsh

change theme

Modify the configuration file of oh my zsh:

code ~/.zshrc

Find the location as shown in the picture: themeI changed the theme to agnoster here, you can find more themes on the official website of oh my zsh, but additional downloads may be required.

Effect

The effect of agnoster is as follows:Effect

Guess you like

Origin blog.csdn.net/qq_37387199/article/details/126733728