ITerm2 + Oh-my-zsh build cool terminal, readers see, ask me can not give a detailed tutorial, now to arrange on.

ITerm2 and OH-my-Zsh are two wonders for longtime users of terminals and Vim.

With iTerm2 and OH-my-ZSH configured, you can not only create a comfortable development environment for yourself, but also greatly improve efficiency.

But before we go into the details, what are iTerm2 and Oh-my-zsh?

Otherwise you won’t even know what you’re doing.

Know what it is before you do it.

There is a shell outside the operating system kernel, and this shell is the shell, which is the bridge between the user and the operating system interaction.

This makes sense: the shell envelops the system, and users who want to interact with the system must go through the shell.

Over time, the shell has also come to be the umbrella name for the scripting language in which the kernel interacts with the user.

Common shells are bash, ZSH, CSH, KSH, ash, and so on.

Bash is the default on Linux, and it was also the default on macOS before Catalina. As ZSH became more popular, macOS began to use ZSH as the default interpreter.

But the default ZSH configuration was a bit annoying, so someone created a configuration file on Github called Oh-my-zsh that saved us a lot of complicated configuration, making oh-my-zsh the most popular ZSH configuration today.

Oh - my - ZSH making address: https://github.com/ohmyzsh/ohmyzsh/projectsCopy the code

By now, you should have a preliminary understanding of shell and OH-my-ZSH.

The iTerm2?

Shell, as the shell of the system kernel, is an abstract concept and an interpreter, but it cannot be operated well as a user.

Therefore, there are such software as terminal. The default terminal of macOS system is Terminal. These terminals are no longer abstract concepts, but visual software, which is very convenient for users to operate.

ITerm2 is one of those programs.

They allow us to either type shell commands or feed back the output to us.

Okay, a bunch of them. Here’s how it works.

1. Basic operations of Vim

A preliminary understanding of Vim operations will be used below.

Just a few simple commands:

Vim <file name> Open the file I insert Editing mode ESC Exit editing mode Shift +zz Save and exitCopy the code

2. Install iTerm2

To install iTerm2, download and install it from the official website.

Website address: http://iterm2.com/downloads.htmlCopy the code

3, install oH-my-zsh

To install something, you must first look for the official website ah.

Primary data is always more valuable than processed secondary data.

The official website of Oh-my-Zsh is https://ohmyz.sh/Copy the code

Click the “Install oh-my-zsh” button on the official website to see how to Install it.

There are two ways to install oH-my-zsh, using curl or wget, depending on your circumstances and preferences.

Curl installation:

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

Wget installation mode:

$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
Copy the code

When the installation is complete, it will look like this:

4. Change the default shell

After the installation is complete, an additional ZSH file will appear in the /bin directory.

You can view it by using the following command:

cat /etc/shells  
Copy the code

Notice that there is a space after cat.

Second, macOS used dash as a terminal until the Catalina version,

If you want to change it to ZSH, you can use the following command:

chsh -s /bin/zsh
Copy the code

Of course, if you regret it and want to go back to dash, use the same CHSH command as above.

chsh -s /bin/bash
Copy the code

5. Change the theme

The installation of the software are installed, now the main is to choose their favorite style.

So what thematic styles are available?

You can view it from the Github address below.

Making address: https://github.com/ohmyzsh/ohmyzsh/wiki/themesCopy the code

There are many themes, all kinds of styles, depending on your personal preference.

Like the lovely theme Cloud with clouds and lightning.

And steeef, which is very simple.

There are also officially recommended ys.

Having selected the theme, the next step is to configure the theme. How?

At this point you can type the following command in iterm2

vim ~/.zshrc
Copy the code

The default theme of oh-my-zsh is robbyrussell. If you want to change it, do as follows:

To modify the file in Vim, press I to enter edit mode, change the value of ZSH_THEME to your favorite theme, press Esc (top left of computer) to exit edit mode, shift+zz to save and exit.

Of course, if you’re not familiar with this, you can open the.zshrc file and change the ZSH_THEME value using a regular editor.

Oh-my-zsh comes with some default themes, which are stored in ~/. Oh-my-zsh /themes by default.

You can see this by typing CD ~/. Oh-my-zsh /themes && ls in the terminal.

In addition to these built-in themes, there are a lot of cool, cool custom themes.

For example, PowerLevel9k.

Powerlevel9k is a really cool thing.

So what do you want to do with these themes?

It’s also very simple, just one more step than using the native theme.

Just download the theme first.

Using PowerLevel9k as an example, download it with Git Clone to the directory where oh-my-zsh places third-party themes.

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
Copy the code

Finally, as before, open the configuration file and set the theme.

Finally, remember source.

source ~/.zshrc
Copy the code

6. Install Powerline and PowerFonts

Powerline is a plugin that oh My ZSH relies on.

This plugin addresses many of the font issues in the oh My ZSH theme.

Of course, this plugin does not have to be installed, but if you encounter garbled characters, you will need to install them.

Why is it garbled?

Because there are some special themes, there are special expressions and symbols. Like powerLevel9k mentioned above.

No more nonsense, go directly to the official website.

Website address: https://powerline.readthedocs.io/en/latest/installation.htmlCopy the code

If you go to the Powerline website, you’ll see that Powerline is written in Python, so it’s easy to install with just one command.

pip install powerline-status
Copy the code

Make sure you have the Python environment and PIP installed before installing it. Python usually comes with the Mac system, so if you encounter:

ZSH: Command not found: PIP.Copy the code

PIP is not installed.

You can also install it by command.

sudo easy_install pip
Copy the code

If there are garbled characters, PowerFonts are not installed yet.

To install git fonts, you need to clone git to your local directory and then run install.sh in the source code.

The specific process is as follows:

# git clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
Copy the code

After the installation is complete, you can set the Font for iTerm2 by iTerm2 -> Preferences -> Profiles -> Text. In the Font area, select Change Font to see what you like and select the Font. Font names with “for Powerline” are not garbled.

7, color preset

Itme2 supports a variety of color themes.

You can see a variety of introductions from the official website, but I won’t go into details here, but mainly talk about the detailed steps.

Website address: https://iterm2colorschemes.com/Copy the code

You can download the color theme file first.

Click the icon on the official website to download it

Of course, it can also be downloaded by running commands

git clone https://github.com/mbadolato/iTerm2-Color-Schemes ~/Downloads/itemcolor
Copy the code

Note that ~/Downloads/ ItemColor refers to the directory where the downloaded files will be placed, and you can change it yourself.

I downloaded it directly from the official website and there are a lot of folders, I’ll just focus on Schemes and Screenshots.

The Schemes folder is where the color theme files are located.

Screenshots are previews of various color themes.

You can select your favorite color theme based on your personal preferences, and then select Preference -> Profiles -> Colors from iterm2 to import the color theme and check it.

8. Command completion

Zsh-autosuggestion is a plug-in for ZSH command completion hints.

The specific process is as follows:

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

Then go to plugins and add zSH-AutoSuggestions.

Alternatively, you can simply open the.zshrc file, go to plugins and add zsh-autoSuggestions.

Remember to save.

Once the installation is complete, the specific effect is as follows. As long as I type op, it will automatically prompt me to type the command open ~/.zshrc, very convenient.

For example, zsh-syntax- considering grammar highlighting is a new plugin for considering new media.

9. Other optimization Settings for iTerm2

For example, you can use keys to set quick shadow and show iterm2 shortcuts.

Setting the background image

Also can set background diaphaneity and fuzzy degree arbitrarily, see your hobby to undertake outfit force.