While researching terminal tools recently, I found that other terminals can output various color text and various prompts, which I could not achieve even with the cool Tabby. It turns out that you need to install OhMyZsh on Linux. Today, I would like to introduce OhMyZsh to you.
SpringBoot e-commerce project mall (50K + STAR) address: github.com/macrozheng/…
OhMyZsh profile
OhMyZsh is an open source tool for managing the configuration of Zsh, a type of Linux command interpreter. Using OhMyZsh can make you look like a programmer with 10 years of experience. OhMyZsh has hundreds of plugins at your disposal, as well as a variety of cool themes. OhMyZsh is so popular that it has 137K+Star on Github!
Introduction of Zsh
CentOS uses Bash as its default command interpreter. Other commonly used commands include sh, CSH, and TCSH. Zsh is more powerful than the default Bash, with a large number of plug-ins for more powerful command completion, command highlighting, and more.
The installation
OhMyZsh is actually a Zsh management tool, we need to install Zsh before installing OhMyZsh.
Install the Zsh
- There are many ways to install Zsh. Using yum is convenient, but OhMyZsh officially recommends installing Zsh
5.0.8
Yum ZSH: Yum ZSH: yum ZSH
yum info zsh
Copy the code
- If your version number is greater than
5.0.8
Yum yum yum yum yum yum yum yum yum yum yum yum yum yum yum yum
yum -y install zsh
Copy the code
- Source Zsh need to download the source code package installed, download address: Zsh. Sourceforge. IO/Arc source….
- First, put the downloaded source package in the specified directory, and then use the following command to decompress the installation;
#Install dependencies
yum -y install gcc perl-ExtUtils-MakeMaker
yum -y install ncurses-devel
#Unpack theTar XVF zsh-5.8.tar.xz CD zsh-5.8#Check whether the installation environment dependency is complete
./configure
#Compile and install
make && make install
Copy the code
- After the installation is complete, run the following command to view the Zsh path:
whereis zsh
Copy the code
- Then add the Zsh path to
/etc/shells
Here we can see all the command interpreters supported by the system;
vim /etc/shells
#Add the following
/usr/local/bin/zsh
Copy the code
- Finally, view the Zsh version number to check whether the Zsh is successfully installed.
zsh --version
Copy the code
Install OhMyZsh
- Next we will install OhMyZsh directly using the following command to install;
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Copy the code
- If you cannot download it, you can create one first
install.sh
Then copy the contents of the file from Github and run the following command to install:
#The sh address: https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh
./install.sh
Copy the code
- After the installation is complete, you will be prompted to modify the default shell used by Linux. Run the following command to view and modify the default shell.
#View the shell currently in use
echo $SHELL
#You can also modify the default shell yourself using the following command
chsh -s $(which zsh)
Copy the code
- After the installation, the configuration file is
.zshrc
The installation directory is.oh-my-zsh
The installation directory structure is as follows.
use
The powerful function of OhMyZsh lies in its rich plug-ins, and the cool interface lies in its rich themes. Here we will introduce them respectively.
Subject to modify
- OhMyZsh’s theme is very rich, with its own theme in
themes
Folder;
- To change a topic, you only need to modify the configuration file
.zshrc
theZSH_THEME
Property, let’s change the theme toaf-magic
;
vim ~/.zshrc
#Modify the following
ZSH_THEME="af-magic"
#Refresh the configuration, which is required after each change
source ~/.zshrc
Copy the code
- The theme effect is as follows.
The use of plug-in
OhMyZsh comes with more than 300 plug-ins, and there are many third-party plug-ins, visible plug-in ecology is very rich, let’s introduce a few good plug-ins.
All of OhMyZsh’s plugins are in the plugins directory.
zsh-syntax-highlighting
Normally, when you type a Linux command, you only know that you have typed a wrong command when you execute it. This plug-in can detect the command in real time.
- To download the plug-in to the specified directory, run the following command.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Copy the code
- Then modify the configuration file
.zshrc
Add plug-ins to pluginszsh-syntax-highlighting
;
plugins=(
git
zsh-syntax-highlighting
)
Copy the code
- The next time you type a command, it will be highlighted and the correct command will appear green.
zsh-autosuggestions
Automatic completion plug-in, input command will automatically prompt relevant commands, use the arrow key → can achieve automatic completion.
- To download the plug-in to the specified directory, run the following command.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Copy the code
-
Then modify the.zshrc configuration file and add the zsh-autosuggestions plug-in to the plugins.
-
At this point, when we input the command prefix, the command will be directly prompted, and then press the arrow key → to achieve automatic completion.
ZSH – history – the substring – search:
Can search command history plug-in, use Ctrl+R shortcut triggered, fuzzy search duration used command.
- To download the plug-in to the specified directory, run the following command.
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
Copy the code
-
Then modify the.zshrc configuration file and add the zsh-history-substring-search plugin to the plugins.
-
Next we can use the Ctrl+R shortcut to trigger, and then command search completion.
docker
Built-in plug-in, can achieve docker command completion and automatic prompt.
-
ZSHRC as a plugin without downloading, directly modify the configuration file, add plug-in docker to plugins;
-
When we enter a docker-starting command, using the Tab key can be prompted and auto-complete.
git
Built-in plug-ins, add a lot of Git shortcut commands.
-
Add git to your plugins by modifying the.zshrc configuration file directly.
-
The plugin provides a number of shortcuts to Git commands, such as the following common commands;
Quick alias | The command |
---|---|
g | git |
gcl | git clone |
ga | git add |
gc | git commit |
ggp | git push |
ggl | git pull |
gst | git status |
gb | git branch |
glg | git log –stat |
- It is very convenient to use the shortcut command!
z
Built-in plug-in, you can quickly jump to the directory of the previous CD.
- Modify the configuration file directly
.zshrc
Add plug-ins to pluginsz
, the final configuration effect is as follows;
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
zsh-history-substring-search
docker
z
)
Copy the code
- So let’s switch to
.oh-my-zsh/custom/plugins
Directory, and then switch to another directory, and then directly usez plug
The command can be switched back.
btop
Our command line terminal has been so cool, and then use the top command to see the running status of the server is a bit of a grade, let’s introduce a better tool btop.
Introduction to the
Btop is a server resource monitoring tool that can be used to view the CPU, memory, disk, network, and process status of a server.
The installation
- First we need to download the bTOP installation package: github.com/aristocrato…
- After the download is complete, unzip to the specified directory and use it
install.sh
Installation can;
#Creating an installation directory
mkdir btop
#Decompress the package to the installation directoryTBZ -c btop CD btop tar -xvf btop-1.1.2-x86_64-linux-musl. TBZ -c btop CD btop#The installation
./install.sh
Copy the code
use
- Btop is very simple to use, straight to use
btop
Command can be run;
btop --utf-force
Copy the code
- After successful operation, the interface is still very cool, server resource information at a glance, no longer want to use the top command;
- Btop also supports mouse interaction, turning the simple command line into a graphical interface. You can select a process to view detailed information.
- According to the
ESC
Key to exit, modify Settings, or view help;
- If you want to uninstall, you can use the following command in the installation directory.
make uninstall
Copy the code
conclusion
OhMyZsh is a great tool that has greatly increased our productivity and made us look more like experienced programmers. Btop also makes our command line terminal cool and never wants to use the top command again. If you want to make your command line terminals cool, try them!
The resources
- OhMyZsh official website: github.com/ohmyzsh/ohm…
- Btop official website: github.com/aristocrato…
In this paper, making github.com/macrozheng/… Already included, welcome everyone Star!