First, let’s start with a beautiful image

1 Introduction to zsh
1.1 Linux Shell
Linux/Unix provides many types of shells. Why so many shells?
Are they for cooking? Let me ask you, why do you have so many similar clothes? Different colors and textures. Writing programs is much more complex than buying clothes, and programmers often have to simplify complex tasks and complicate simple ones. A skilled programmer who is dissatisfied with a shell will rewrite one, gradually forming some standards. The commonly used shells include sh, bash, csh, etc. To find out how many shells your system has, you can use the following command:
cat /etc/shells
The output will be as follows:

1.2 Introduction to zsh
Zsh is a powerful shell for Linux. Although most Linux distributions come with bash shell
installed by default, this does not diminish the enthusiasm of geeks for zsh. Almost every Linux distribution includes zsh, which can usually be installed using package managers like apt-get, urpmi, or yum.
Zsh has the following main features:
-
Out-of-the-box, programmable command-line completion helps users input various parameters and options.
-
Shares command history across all shells started by the user.
-
With extended file globbing, it can expand filenames like the find command without using external commands.
-
Improved variable and array handling.
-
Allows editing of multi-line commands in the buffer.
-
Multiple compatibility modes, such as masquerading as Bourne shell when running with /bin/sh.
-
Customizable prompt presentation; includes displaying information on the right side of the screen and automatically hiding when typing long commands.
-
Loadable modules provide various additional support: complete TCP and Unix domain socket control, FTP client, and extended mathematical functions.
-
Fully customizable.
1.3 Ultimate Configuration of zsh and oh-my-zsh
I chose to use zsh after seeing this article: The Ultimate Shell – Zsh, attracted by its auto-completion and completion features. Official website: www.zsh.org
I chose oh-my-zsh, which is an extension of zsh’s functionality, providing convenient plugin management, theme customization, and beautiful auto-completion effects.
I found it while looking for zsh projects on GitHub, tried it out, and found it very convenient. It doesn’t require the complex configuration mentioned in the article; you just need to configure the names of some plugins to use the corresponding features.
Official website: https://github.com/robbyrussell/oh-my-zsh
2 Installing zsh
2.1 Installing zsh
For a typical Ubuntu system, after configuring the correct sources, you can directly enter the following command to install:
sudo apt-get install zsh
2.2 Configuring zsh
Configuring zsh is a vast subject, so I won’t elaborate here. I’ll provide a configuration file that you can download and place in the zsh configuration directory for direct use. (A French friend of mine prepared it, and it’s quite handy.)
Copy .zshrc to the corresponding user’s home directory (you can also copy your bash configuration file (~/.bash_profile or ~/.profile, etc.) to zsh’s configuration file ~/.zshrc, as zsh is compatible with bash).
2.3 Replacing bash and Setting as Default Shell
sudo usermod -s /bin/zsh username
or
chsh -s /bin/zsh
chsh -s `which zsh`
If you want to switch back to bash:
chsh -s /bin/bash
Of course, if you really don’t want to make zsh your default shell but still want to use it, you can enter zsh
each time you log in and type exit
to exit.

2.4 Installing oh-my-zsh
Using zsh directly can be quite painful because zsh is powerful but too complex, so oh-my-zsh is needed to simplify it.
Directly download the package from GitHub using git
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
Backup the existing zshrc and replace zshrc
cp ~/.zshrc ~/.zshrc.orig
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Directly use the script to install
cd oh-my-zsh/tools
./install.sh
You can directly use the following command to install
curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
wget
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Essentially, it downloads and executes the install.sh script from GitHub, located at oh-my-zsh/tools/install.sh
.
Configuring Themes
oh-my-zsh integrates a large number of themes, located in oh-my-zsh/theme
.
To configure a theme, you can modify the environment variable ZSH_THEME
in ~/.zshrc
.
ZSH_THEME="agnoster" # (this is one of the fancy ones)
If you find there are too many themes, you can choose to use random mode, allowing the system to randomly select one.
ZSH_THEME="random" # (...please let it be pie... please be some pie..)

For detailed theme information, please refer to the zsh theme introduction.
Configuring Plugins
Modify ~/.zshrc
in plugins
plugins=(git bundler osx rake ruby)
For detailed plugin information, please refer to the zsh plugin introduction.
Updating oh-my-zsh
By default, you will be prompted to check for updates every few weeks. If you want ZSH to automatically update itself without prompting you, modify ~/.zshrc
disable_update_prompt = true
To disable automatic updates, modify ~/.zshrc
disable_auto_update = true
Of course, you can also choose to update manually.
If you want to upgrade at any time (maybe someone just released a new plugin, and you don’t want to wait a week?), you just need to run:
upgrade_oh_my_zsh
Uninstalling oh-my-zsh
If you want to uninstall oh-my-zsh
, just execute uninstall_oh_my_zsh zsh
from the command line. This will remove it and restore your previous bash or zsh configuration.
uninstall_oh_my_zsh zsh
All articles from this public account have been organized into a directory. Please reply with “m” in the public account to get it!
Recommended reading:
Get lost, regular expressions!
3 crashes in 1 month! A review of the 10 major outages in 2021.
55 knowledge points of firewalls explained in 53 images.
5T technology resources giveaway! Including but not limited to: C/C++, Linux, Python, Java, PHP, artificial intelligence, microcontrollers, Raspberry Pi, etc. Reply with “1024” in the public account to get it for free!!