To do a good job, you must first configure its terminal.

Terminal is the place where programmers interact most with computers, which is also a high frequency factor. If you have a good and good-looking terminal, it will directly improve your quality of life. This article shares how to configure an efficient, user-friendly, and beautiful terminal. The method works for MacOS and Linux, but if you’re Windows, try the Linux subsystem.

Tools used

ZSH, oh-my-zsh, powerLevel10k, if you see that these are familiar and in use, you don’t need to look further.

Let me explain these three tools.

zsh

Shell terminals in Linux include bash, KSH, TCSH, ZSH, fish, and so on. Bash is of course the number one user, since most Linux distributions default to bash, and ZSH is the number two user. Why ZSH? Because ZSH has more customization options than the default bash, and supports extensions. So ZSH can achieve more powerful command completion, command highlighting and a number of cool features.

oh-my-zsh

The default ZSH configuration is a bit cumbersome. So a user named robbyrussel created a profile on GitHub called oh-my-zsh, which is by far the most popular ZSH configuration.

powerlevel10k

Oh-my-zsh has hundreds of native themes, as well as hundreds of external themes, but the most widely used and best reviewed theme is PowerLevel10k, which is compatible with PowerLevel9k and offers a 10-100x performance improvement. 🌟 is available on GitHub at 20.8K.

The configuration steps

Clone the OH-My-ZSH project:

git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
Copy the code

Copy.zshrc

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Copy the code

3. Change your default Shell

ZSH is installed on MacOS by default.

chsh -s /bin/zsh
Copy the code

Now you can see that terminal has changed:

Ubuntu does not have ZSH installed by default.

# installation ZSH
sudo apt-get install zsh
To switch ZSH to the default shell, enter the command and password
chsh -s /bin/zsh
Copy the code

4. Install PowerLevel10k

If you have git installed on your computer, clone it directly into the oh-my-zsh plugin directory as follows:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Copy the code

Users in mainland China can use the official image on gitee.com to speed up the download

git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Copy the code

In order to better display folders, emoticons and other ICONS in the terminal, the official recommendation you install font, visit the link at the end of the article to download the font, double click to install. If you are MacOS and using Iterm2, execute p10k configure and select Yes to automatically install the recommended fonts.

5, configuration,

Modify ~/.zshrc to add the PowerLevel10k theme.

ZSH_THEME="powerlevel10k/powerlevel10k"
Copy the code

Restart the terminal, then type p10k configure to configure PowerLevel10k, install your preferences to configure:

6. Installation and configuration of common plug-ins

Environment configuration is good, we also need to add some plug-ins to make the terminal better use, introduce me to use a few plug-ins, efficient leverage.

The git plug-in

Git is enabled by default. You can use abbreviations for various git commands, such as:

Git add --all GCMSG git commit -mCopy the code

Git command abbreviations

cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh
Copy the code
Z plug-in

The Z plugin is a similar component of the Autojump plugin built into oh-my-Zsh and basically contains all functions. Using Z allows you to switch file paths fastest. The Z plug-in remembers every path you jump to on the command line and keeps track of how many times each path was visited, so it can often guess which path you want to go to. By default, oh-my-zsh is installed with z plugins, which can be found in the following directory: ~/. Oh-my-zsh /plugins

Examples:

  • Z foo goes to the directory that best matches the keyword foo
  • Z foo bar Indicates the level matching. Keyword foo is matched first and then the directory of keyword bar is matched
  • Z -r foo Displays the directory with the highest rank in the list of directories that match keyword foo
  • Z -t foo Enters the most recently accessed directory in the list of directories matching keyword foo
  • Z-l foo Lists all directories that match the keyword foo

Any directory that you visit on your terminal using CD, it will log it, and then you can use it next time in any working directory and just use the z + directory name to go in.

To enable: modify ~/.zshrc and add z plugin:

plugins=(
    git
    z
)
Copy the code
zsh-autosuggestions

Source Py38env /bin/activate activate: source Py38env /bin/activate activate: source Py38env /bin/activate

Installation method:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Copy the code
zsh-syntax-highlighting

Shell syntax highlighting, this plugin must install.

Installation method:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
Copy the code

Finally, make sure ~/.zshrc has these plugins enabled:

plugins=(
    git
    z
    zsh-autosuggestions
    zsh-syntax-highlighting
)
Copy the code

The last

Oh-my-zsh can greatly improve your terminal operation efficiency, when you forget the path, directly z + the key words you can think of, you can jump to the desired path. When you type a command, it will automatically help you recall the previous command, when you type a wrong command, the command will turn red, green when correct, which is very considerate. Powerlevel10k is all about making your terminal high-end and elegant.

By the way,New terminal WindowsIt’s getting better and better. Here are some screenshots: Windows partners can go to the end of the link to see.

If you find it helpful, feel free to like it, view it, share it with your friends, follow it, and learn a little technique every week.