preface

ITerm2 is an open source, free alternative to Terminal, with a variety of useful features such as split screen, custom color matching, background images, various shortcuts, AutoComplete, and so on, it can be said that MacOS is the most useful Terminal tool. For MacOS 10.12 or later

Oh My Zsh is an open source framework for managing Zsh configurations, with plugins such as code highlighting, code hints, directory indexing, various language support, and a number of themes to use to make the terminal interface more aesthetically appealing.

About the ZSH

A powerful shell, but native ZSH is too difficult to configure, with oh My ZSH you can configure ZSH quickly.

MacOS comes with ZSH, but the terminal uses bash by default. About the ZSH

Copy the code

A iTerm2.

Iterm2.com/ can be downloaded directly from the official website

After the installation is complete, a ZSH file will be displayed in the /bin directory.

The Mac system uses DASH as the terminal by default. You can run the following command to change the default terminal to ZSH:

chsh -s /bin/zsh
Copy the code

To change back to dash, run the CHSH command again:

chsh -s /bin/bash
Copy the code

Install Oh my ZSH

Curl curl curl curl curl curl curl curl curl curl curl curl curl curl curl curl curl curl curl

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

Installation commands and screenshots after installation:

Oh-my-zsh 网 址 : github.com/ohmyzsh/ohm…

Three, configuration,

After installing oh my ZSH, you will have.zshrc configuration files and.oh-my-zsh directories in the user root directory of the Mac. All files are hidden and can be quickly displayed/hidden by using the shortcut key [Command + shift +.]

.oh-my-zsh file ├─ plugins # ├─── Themes # ├── ├── themes # ├── ├─ ├── themes #Copy the code

3.1 Configuring Plug-ins

For a list of Plugins available with Oh My Zsh, refer to the official wiki/Plugins.

Recommended plug-ins:

  1. Git: displays information about your Git project, as well as shortcuts to various Git commands.
  2. Z: fast directory jump. After entering a directory, you can quickly jump to the directory by using the directory name z without entering the full path.
  3. ZSH -syntax-highlighting: Common commands highlighting, error red, correct green, e.g. ** CD,ls,clear ** etc.
  4. Zsh-autosuggestions: command prompt, when entering gray words suggest recommended commands, directly keyboard ➡️ complete, not TAB key;

Note: git and z plug-ins come with oh my ZSH and can be directly configured to use. ZSHRC files. The other two need to be installed.

Install ZSH — syntax highlighting:

Git clone github.com/zsh-users/z… ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Install the ZSH – autosuggestions

Git clone github.com/zsh-users/z… ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

The preceding two commands will clone the plugins to ~/. Oh-my-zsh /custom/plugins

To configure the Plugins to use, open the.zshrc configuration file in the user’s root directory, find the Plugins=() line, and add the Plugins to it, space apart.

plugins=(git z zsh-syntax-highlighting zsh-autosuggestions)

3.2 Configuring a Theme

For third-party Themes and previews, see the official wiki/ external-Themes

Recommended topics:

  1. Robbyrussell: Default theme, concise, used in this example.
  2. Ys: Built-in, more concise, if you feel the ICONS in the default theme are inconvenient, ICONS in the default theme are replaced by symbols.
  3. Agnoster: built-in, more people use, need to rely on Powerline font.
  4. Powerlevel9k: third party, can display more system status information, need to be installed separately, and need to rely on Powerline font.

ZSH_THEME=”robbyrussell” in the.zshrc configuration file. You can change it to ZSH_THEME=”agnoster”, which requires Powerline font. The use of the Powerline font is described below.

3.3 iTerm2 theme color matching

I use Dracula terminal run the command:

Git clone github.com/dracula/ite…

See the.itermcolors file in the download

  1. Open the iTerm2;
  2. Profiles -> Colors -> Color Presets -> import -> Select the downloaded preset file
  3. Check imported presets

3.4 Setting the iTerm2 font

3.4.1 Built-in Font Settings

3.4.2 Third-party Font Settings

We have mentioned agnoster font above, which comes with the system and is used by many people. It needs to rely on Powerline font, third-party font and preview, please refer to the official Powerline website

  1. Installing Powerline is still simple and requires only one command:

    pip install powerline-status –user

ZSH: Command not found: PIP if you have not installed PIP, you may encounter ZSH: Command not found: PIP2. Install PIP:

sudo easy_install pip

Go to this time you will find that you can not go all the time, you need to know the knowledge point:

Python2.7 comes with the Mac. You can enter Python on the terminal to enter python compilation mode. If you want to install Python3, you need to install Python3 manually.

Install Python3

Because after python3 is installed, it comes with PIp3

Enter brew install python3 at the terminal

Terminal input:

Which PIp3 or which python3

Note:

HomeBrew is useful here, the installation process is not much explained, you can understand

Returning to the subject: Installing powerline The following command is not available

PIP install powerline-status –user pip3 install powerline-status –user

Finally: Fonts for Powerline

Git clone:

 1.git clone :git clone https://github.com/powerline/fonts.git --depth=1
 2. cd to folder: cd fonts
 3. run install shell: ./install.sh
Copy the code

To install the font library, first clone the project git locally and then execute install.sh in the source code. Create a new folder in your preferred location, such as ~/Desktop/OpenSource/

Once the Font library is installed, set the Font for iTerm2 by iTerm2 -> Preferences -> Profiles -> Text, select Change Font in the Font area and find the Meslo LG Font. L, M and S are optional, depending on personal preference

3.5 Background Settings

Background Settings [Profiles] -> [Colors], set the background or set transparency + frosted glass.

3.6 iTerm2 status bar Settings

The high bar is the CPU, memory and network status bar at the top of the preview. 1. [Profiles] -> [Session] -> [check Status bar enabled] -> [Configure Status bar]

2. [drag required state information] -> [Auto Rainbow]

Common Shortcut keys

The command instructions
command + t The new label
Command + arrow keys or numbers Switching between
command + d Vertical split screen
command + shift + d Horizontal split screen
Command + option + arrow key Switch the home screen
command + w Close tabs or split screens
ctrl + l The clear screen clearing
ctrl + u Clear current line
ctrl + a To the beginning of a line
ctrl + e To the end of each line

Finally, thanks to the blogger: vincef0ng.cn/post/iterm2… And segmentfault.com/a/119000001…