Introduction
What is Oh My Zsh
- Oh My Zsh is a community-driven command line tool, and as its homepage says, Oh My Zsh is a way of life. It is based on the zsh command line and offers theme configuration, plugin mechanism, and already built-in convenience operations. It gives us a whole new way to use the command line.
- Oh My Zsh is an extended toolset based on the zsh command line, providing a rich set of extended features.
Official Website
If you are interested in more, you can go to the official website for details.
Preparation
Install zsh to replace bash, etc. The default shell for macOS systems is currently zsh, other Linux systems may need to install zsh first.
Ubuntu:
1 2 3 4
# Install zsh apt install zsh # set zsh as the default shell (if you don't set it, start zsh with the direct zsh command) chsh -s /bin/zsh
Centos:
1 2
yum install zsh chsh -s /bin/zsh
Same for the others.
Install git, same as above using apt or yum package manager.
Finally you need curl or wget, install the same as above.
Install
curl installation
|
|
wget installation
|
|
There is no difference between the two installs.
Themes
I usually use the steeef theme that comes with it, which is pretty clean and easy to use.
If you want to change the theme, just edit the ~/.zshrc
file and replace ZSH_THEME with the theme you like after it.
The .zshrc file.
The
.zshrc
file does the same thing as the.bashrc
file. The default shell for most unix systems used to be bash, and the .bashrc file is the configuration file for bash.The relevant explanation in the online help file, as viewed with the man bash command, is as follows. .bashrc - The individual per-interactive-shell startup file.
This file mainly stores personalized settings, such as command aliases, paths, etc.
Each time you modify .bashrc, use source ~/.bashrc (or . ~/.bashrc) to immediately load the modified settings and make them take effect. Typically .bashrc is called explicitly in the .bash_profile file.
When you log in to linux and start bash, it will first read the ~/.bash_profile file, so ~/.bashrc will be executed and your personalized settings will take effect.
Plugins
The management of omz plugins is very simple, there are two plugins directories, where user is your username:
/Users/user/.oh-my-zsh/plugins
The official plugins directory. This directory is already preloaded with many useful plugins, which only need to be activated manually.
/Users/user/.oh-my-zsh/custom/plugins
Third-party plugins directory, shortcut command:
$ZSH_CUSTOM/plugins
.
To install the plugins, just download the plugins to the third-party plugins directory, and then add the name of the corresponding plugins to the plugins
variable in the ~/.zshrc
configuration file.
Download Plugin
zsh-syntax-highlighting
|
|
zsh-autosuggestions
|
|
If you feel that Tab key is not convenient for completing, you can also customize the shortcut keys for completing. For example, to set comma completion, just add the following line to
~/.zshrc
file.
1
bindkey ',' autosuggest-accept
Enable Plugin
In the .zshrc file set.
|
|
Enable other plugins in the same way.
Configuring to take effect
One way to do this is to exit the terminal and reopen it, another, more common way is to use the source
command I described earlier.
|
|