ITERM2 + OH My ZSH to create a comfort terminal experience

Write in front

Final renderings:

ImageInitIterm

This article is heavily plagiarized from: https://www.jianshu.com/p/7de. ..

Due to some bugs in the layout and original text, this article was created by referring to the search engine and original text.

Because both powerline and homebrew need to install the command line tool, students with superior network conditions can install XCode and open it once before executing the following content in this article (it will initialize the installation of components), and save it in iterm2 in the future. Waiting time in.

In addition, git is also necessary. You can download and install it yourself, except for the network without any pits:

https://git-scm.com

Introduction At this point, this article assumes that you have installed the git environment and xcode (command line tools). If you encounter a prompt that you cannot find a git command or need to install the command line tool, I won’t repeat it in the article.

Download iTerm2

You can go directly to the official website to download: https://www.iterm2.com/

After the installation is complete, there will be more in the /bin directory Export a zsh file.

Mac system uses dash as the terminal by default, you can use the command to modify the default zsh:

chsh -s /bin/zsh

If you want to change back to the default dash , You can also use the chsh command:

chsh -s /bin/bash

OK, this is the initial look of iTerm2, let’s beautify it and make it better use!

ImageInitIterm

Install Oh my zsh

There are two installation methods, you can use curl or wget, depending on your environment or preference:

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

Installation command and screenshot after installation:

ImageInitIterm

oh-my-zsh open source address: https://github.com/robbyrusse…

Install PowerLine< /h3>

Powerline official website: http://powerline.readthedocs….

The way to install powerline is still simple, and only one command is needed:

pip install powerline -status --user

Students who have not installed pip may encounter zsh: command not found: pip.

ImageInitIterm

Use the command to install pip:

sudo easy_install pip

After installation, execute the command to install powerline again.

ImageInitIterm

Installing PowerFonts

To install the font library, you need to first git clone the project to the local, and then execute install.sh in the source code.

Create a new folder where you are used to, such as: ~/Desktop/OpenSource/

ImageInitIterm

Execute the git clone command in this folder:

# git clone
git clone https://github.com/powerline/fonts.git --depth=1
# cd to folder
cd fonts
# run install shell
./install.sh

The execution results are as follows:

ImageInitIterm

After installing the font library, let’s set the font of iTerm2. The specific operation is iTerm2 -> Preferences -> Profiles -> Text, select Change Font in the Font area, and then find the Meslo LG font. There are L, M and S options, depending on personal preference:

ImageInitIterm

Install the color scheme

The color scheme becomes very useful when using VIM or Colorful Log. At the same time The interface will not be as rigid as black and green.

Also use git clone to download the source code for installation:

cd ~/Desktop/OpenSource
git clone https://github.com/altercation/solarized
cd solarized/iterm2-colors-solarized/
open .

In the open finder window, double-click Solarized Dark.itermcolors and Solarized Light.itermcolors to install light and dark colors:< /p>

ImageInitIterm< /span>

Enter iTerm2 again -> Preferences -> Profiles -> Colors -> Color Presets, choose one of these two colors according to personal preference:

< span class="img-wrap">ImageInitIterm

Install the theme

Download the agnoster theme and execute the script installation:

cd ~/Desktop/OpenSource
git clone https://github.com/fcamblor/oh -my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
./install

Execute the above command will copy the theme to oh my In zsh themes:

After the copy is complete, execute the command to open the zshrc configuration file and change the field after ZSH_THEME to agnoster.

vi ~/.zshrc

ImageInitIterm

After the modification is completed, click esc to call up the vi command, enter: wq to save and exit vi mode.

At this time, after the command+Q or source configuration file, iTerm2 has changed its appearance:

ImageInitIterm

Install the highlight plugin

This is oh my zsh A plug-in of, the installation method is similar to the theme:

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh -syntax-highlighting.git
vi ~/.zshrc

At this time, we open the zshrc file again for editing. Find the plugins, there should already be git in the plugins, we need to add the highlighting plugin:

ImageInitIterm

Please ensure the order of plugins, zsh-syntax-highlighting must be the last one.

Then add in the last line of the file: source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Press Click esc to call up the vi command, enter: wq to save and exit vi mode.

Execute the command to make the modification effective:

source ~/.zshrc

So far you are done, please see the final rendering:

ImageInitIterm

The background image is taken from the 4K wallpaper (nearly 12MB in size) of Microsoft Surface Studio, very beautiful, you can pick it up if you need it:

https://pan.baidu.com/s/18jNr. ..

The way to change the background image: iTerm2 -> Preferences -> Profiles -> Window -> BackGround Image just check the image.

Selectable, command completion

Same as the installation method of code highlighting, this is also a zsh plug-in called zsh-autosuggestion, which is used for command suggestion and completion.

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-autosuggestions
vi ~/. zshrc

Find plugins and add this plugin:

ImageInitIterm

Plugin effect:

< img src="/wp-content/uploads/images/os/macos/1626797496103.svg" alt="ImageInitIterm" title="ImageInitIterm">

Github: https://github .com/sirius1024…

Like Star, please

Leave a Comment

Your email address will not be published.