Mac OS terminal iTerm2

I had been using the terminal of Mac OS, and I thought it was ok. Later, I saw the live video of Onevcat and found that he used iTerm, which was really very easy to use, so I began to pour myself.


1. Download and install

Official website download address

You can either open it directly or drag it to the Applications directory.

2. Preferences

Menu – > Preferences – > Profiles

The list on the left shows all of your profiles. Currently there is only one Default in the list, which is the Default window template Profile for iTerm. Let’s create our own window Profile.

Click the + sign at the bottom of the list to create a new profile

Fill in the basic configuration in General:

  • Name: indicates the configuration file Name
  • Shortcut Key: Shortcut Key to open the window
  • Tags: enables you to quickly find the configuration file in the list on the left
  • Badge: To display your Badge on the window.

Colors Sets the color related configuration:

  • Foreground: Foreground color, window text color
  • Background: window Background color
  • Links: Color of Links
  • Selection: Indicates the background color of the selected content
  • Selected Text: Selects the color of the Text
  • Badge: The color of the Badge
  • Cursor: Indicates the color of the Cursor

You can also download theme matching from the Internet and use the theme configured by others to download the address. After downloading, go to Color Presets – > Import and select the folder where you want to download the theme and click Open to Import Then it’s ready to use.

Change the MAC terminal font color

Text set the window Text related configuration:

  • Cursor: The style of the Cursor
  • Font: Text Font

Set window-related configuration in Windows:

  • Transparency: Window Transparency
  • Background Image: Indicates the Background Image of a window

3. Highlights

Fast hide and show

Profiles — > Keys — > Hotkey, selected. The default shortcut Keys are option + Space


ITerm2 can automatically complete commands. Enter several characters and press Command +. The automatic completion window is displayed, listing the commands that have been used.

The timeline

If you want to see what you’ve done in the last few days, use the timeline function.

Shortcut key: Command + Option + B

Intelligent selected

In iTerm2, double click to select and triple click to select the entire row. Can recognize urls, quoted strings, email addresses, etc.

In iTerm2, copy is selected. Any selected string is placed in the system clipboard.

The powerful Command key

Hold command:

  • You can drag and drop the selected string
  • Click on theurl: Call the default browser to access the url
  • Click File: call the default program to open the file
  • Click on folder: InFinderTo open the folder
  • At the same time hold down theoptionKey, which can be selected as a rectangle

Common Shortcut keys

shortcuts instructions
Command + Shift + H Pasting history
Command + Shift + ; History Command Record
Command + D The same window is split horizontally
Command + Shift + D The same window vertical split screen
Command + Option + E Quick preview of all Windows
Command + / Highlight the current mouse position
Command + T A new window
Command + W Close the window
Command + left and right arrow keys Switching window
Command + Up and down arrow keys Scroll up and down
The Command + digital Switches to the specified window
Command + , Turn on preferences
Command + F Intelligent search


1. Download and install

ZSH comes with the Mac system and is usually not the latest version. If you need the latest version, you can install it through Homebrew.

brew install zsh
Copy the code

You can run the ZSH –version command to view the ZSH version.

Once the installation is complete, set ZSH to the default Shell.

chsh -s /bin/zsh
Copy the code

2. Install OH My ZSH

Install with CRUL:

sh -c "$(curl -fsSL"
Copy the code

Install using wGET:

sh -c "$(wget -O -)"
Copy the code

Installation successful:

Cloning Oh My Zsh... Cloning into '/root/.oh-my-zsh'... remote: Counting objects: 712, done. remote: Compressing objects: 100% (584/584), done. remote: Total 712 (delta 15), reused 522 (delta 4), pack-reused 0 Receiving objects: 100% (712/712) and 443.58 KiB | 27.00 KiB/s, done. Resolving deltas: 100% (15/15), done. Checking connectivity... done. Looking for an existing zsh config... Using the Oh My Zsh template file and adding it to ~/.zshrc Copying your current PATH and adding it to the end of ~/.zshrc for you. Time to change your default shell to zsh! __ __ ____ / / _ ____ ____ ____ ____ _____ _____ / / __ / __ / __ \ / __ ` __ \ / / / / / _ / / ___ / __ / / / _ / / / / / / / / / / / / __ / / / / _ (__) / / / \ ____ _ / _ / _ / / __ / / _ \ __, / / ___ / _____ there comes / __ / / __ / / /... is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us at p.p.s. Get stickers and t-shirts at the code

After installation, the ~/.bashrc file of the default Shell is no longer loaded by default, and is replaced by ~/.zlogin and ~/.zshrc. So if you configure some Settings in ~/.bashrc, you need to copy them to ~/.zshrc.

Oh my ZSH directory structure

Check the structure of the ~/. Oh-my-zsh directory

~ ls ~/.oh-my-zsh cache           log             templates
LICENSE.txt     custom    themes       lib             plugins         tools
Copy the code
  • Lib provides a script library for core functionality
  • Tools Provides quick tools for installation and upgrade
  • The location where plugins are installed
  • Templates is the location of the built-in templates
  • The location where the themes file exists
  • Custom personalization directory, self-installed plug-ins and themes can be placed here

Configuration of 3.

ZSH configuration is concentrated in ~/.zshrc, which is opened with Vim or your favorite editor.

You can define your own environment variables and aliases here. Of course, oh My ZSH automatically reads and sets the current environment variables at installation time, and you can continue to append other environment variables.

Alias Settings:

ZSH can not only set a generic alias, but also set the corresponding open program for the file type, such as:

  • alias -s html=vi“Means you type on the command linehello.html.zshIt opens automatically for youvimAnd readhello.html;
  • alias -s gz='tar -xzvf'Is the suffix of automatic decompressiongzZip package.
alias cls='clear' alias ll='ls -l' alias la='ls -a' alias vi='vim' alias javac="javac -J-Dfile.encoding=utf8" alias Alias -s rb=vi # grep --color=auto alias -s rb=vi # Alias -s py=vi # Alias -s py=vi # Alias -s js=vi alias -s c=vi alias -s Java =vi alias -s TXT =vi alias -s gz='tar -xzvf' alias -s TGZ ='tar -xzvf' alias -s zip='unzip' alias -s bz2='tar -xjvf'Copy the code

Theme setting:

Oh my ZSH offers dozens of themes, with files under ~/. Oh-my-zsh /themes. You can choose your own or write your own themes.

ZSHRC to set the theme, the default theme is ZSH_THEME= “robbyrussell”

ZSH_THEME=”random”, the theme is set to random, so that each time we open a window, we randomly select one of the default themes.

Plug-in Settings:

Oh-my-zsh project provides a complete system of plugins. By default, more than 100 plugins are provided in ~/. Oh-my-zsh /plugins, which can be used according to your actual learning and working environment. Just open the ZSH file in the relevant directory and take a look. ZSHRC plugins are also configured in.zshrc. If you find the plugins keyword, you can load your own plugins. Git is loaded by default.

plugins=(git zsh-autosuggestions autojump zsh-syntax-highlighting)
Copy the code
The installationzsh-autosuggestions
git clone git:// $ZSH_CUSTOM/plugins/zsh-autosuggestions
Copy the code

Added to the plugins

The installationzsh-syntax-highlighting
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Copy the code

Added to the plugins

Uninstall oh my ZSH

Run the uninstall_OH_my_zsh command on the TERMINAL.

Refer to the article

The ultimate Shell ZSH

ZSH full course guide