To do a good job, he must sharpen his tools. Play with the macOS terminal.

The first step is to install HomeBrew as a necessary package management tool for macOS. If you have not installed HomeBrew, you can run the following command to install it. If you have installed HomeBrew, you can run the following command to update it.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Copy the code

Git macOS usually comes with ZSH, but the version is relatively early. Let’s update it first so that we can use the latest features.

brew install zsh
Copy the code
==> Downloading https:/ / homebrew.bintray.com/bottles/zsh-5.7.1.high_sierra.bottle.tar.gz# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #100.0%
==> Pouring zsh-5.71..high_sierra.bottle.tar.gz
/usr/local/Cellar/zsh/5.71.: 1.515 files, 13.3MB
Copy the code

Step 3 switch to ZSH and install oh-my-zsh to see the shell currently in use

$ echo $SHELL

/bin/bash
Copy the code

View the installed shell

$ cat /etc/shells

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
Copy the code

Switch to a ZSH

chsh -s /bin/zsh
Copy the code

Restart the terminal to use ZSH.

Next, install oH-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Copy the code

After the installation, the terminal displays the following information:

____  / /_ ____ _____ __ ____ _____//_ / __ \/ __` __ \ / / / / / _ / / ___ / __ / / / _ / / / / / / / / / / / / _ / / / / _ (__) / / / \ ____ _ / _ / _ / / _ _ - / / / \ __, / /___/____/_/ /_/ /____/.... is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us at https://twitter.com/ohmyzsh. p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.Copy the code

Step 4: Configure oh-my-zsh

Open the oh-my-zsh configuration file

Open the ZSHRC file for editing, or you can use the Vim editor

open ~/.zshrc
Copy the code

I use VS Code

open ~/.zshrc -a Visual\ Studio\ Code
Copy the code

The theme

ZSH_THEME is the oh-my-zsh theme configuration. The GitHub Wiki page of oh-my-zsh provides a list of themes. When ZSH_THEME=random is set to ZSH_THEME=random, a random theme is used every time the terminal is opened.

The plug-in

Plugins =(git osx autojump ZSH – autotext-text-considering) Zsh-autosuggestions and zsh-syntax-considering are self-defined plug-ins, which need to clone the plug-in into the specified plug-in directory with Git:

Autoprompt plug-in

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
Copy the code

Syntax highlighting plugin

git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
Copy the code

If other plug-ins are required, you can install them by yourself. If no plug-in is installed, an error message will be displayed when the terminal is started. Install the corresponding plug-in as prompted.

Update the configuration

source ~/.zshrc
Copy the code

The configuration takes effect after being updated.