Use iTerm2 and zsh

Developers should chase beauty and efficiency! Use a fantastic and productive terminal is better for developing great apps.

In this tutorial, you will learn to:

  • install iTerm2 and a little config
  • install zsh
  • install oh-my-zsh
  • powerline10k theme
  • many zsh plugins

# Install iTerm2

Go to the official website https://iterm2.com to download it.

After installed, you should set it to the default terminal by clicking the menu bar.

image-20210620215206813

I recommand to set the iTerm2 theme to "minimal". Open the preference - Appearance - General - Theme, and change it.

image-20210620220214500

# Install zsh

If you're using macOS 10.15 or above, you should ignore this part. Because zsh is already set to the default shell.

To install zsh, just use brew install zsh. Then, to set it as the default shell, use chsh -s /bin/zsh.

After doing that, restart your terminal. You can check if the setting is all right using echo $SHELL, the output should be /bin/zsh.

# Install oh-my-zsh

Oh-my-zsh is a tool to enhance zsh. To install oh-my-zsh, use:

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

To learn more about oh-my-zsh, you can visit https://ohmyz.sh/#install.

# Install powerline10k

Powerline10k is more than a zsh theme. It has features like instant promt.

To install powerline10k, make sure you installed oh-my-zsh first. And then, use:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

After cloning, open the file ~/.zshrc by vim ~/.zshrc (you can use any other editor to edit it). Find the line including "ZSH_THEME", and change it to ZSH_THEME="powerlevel10k/powerlevel10k".

image-20210620215026638

After doing that, save your change. And type the command:

source ~/.zshrc

to refresh your terminal environment. You should see the configuration page of powerline10k.

image-20210620215525068

Follow the configuration, and you can custom your own terminal!

To learn more about powerline10k, you can visit https://github.com/romkatv/powerlevel10k.

# Install zsh plugins

To make full use of zsh, you can install many plugins. I recommand the following:

plugins=(
git
git-open
osx
tmux
extract
zsh_reload
z
per-directory-history
command-not-found
colored-man-pages
zsh-syntax-highlighting
zsh-autosuggestions
)

Many of them are already integrated with oh-my-zsh, except git-open, zsh-syntax-highlighting and zsh-autosuggestions.

You can install them by the following commands:

  • zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  • git-open
git clone https://github.com/paulirish/git-open.git $ZSH_CUSTOM/plugins/git-open

To enable the plugins, edit ~/.zshrc, and find the plugins, change them to the plugin list above.

image-20210620220057517