Search 

Terminal + ZSH

Nam Hoai Nguyen
Nam Hoai Nguyen
Make your terminal looks like better. A collection of console terminal in serveral operation system.
In this note, I used iTerm2 for MacOS. If you use windows, you can use Windows Terminal + WSL

Install ZSH + Oh My ZSH

Ubuntu + WSL

1sudo apt install zsh
1# check installed
2zsh --version
3
4# make zsh to default bash
5chsh -s $(which zsh) # need to logout and login again
6
7# check
8echo $SHELL # /bin/zsh 

MacOS

From MacOS Catalina (10.15), ZSH became the default Terminal and has remained the default in subsequent release

Installation Oh My ZSH

1# Install oh my zsh
2sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Plugins

After install plugins (choose options install with oh my zsh), put theme in ~/.zshrc
1# example (for me only)
2plugins=(git zsh-autosuggestion zsh-syntax-highlighting z docker docker-compose npm)

Fonts + Themes

Install Nerd Font (It provides for programing high number icons)
Installation themes (for iTerm2 + Terminal MacOS)
  1. Download and install theme
    1. My theme customization: Github Repository
  1. Open iTerm2 → Preferences → Profile → Color
  1. Color presets → Imports
  1. Choose file *.itermcolors downloaded in step 1
  1. Change theme to new theme is imported
Install theme powerlevel10k
1git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Change zsh theme to “powerlevel10k”
1# OPEN ~/.zshrc
2ZSH_THEME="powerlevel10k/powerlevel10k"

Aliases

Sometimes you may encounter commands that are too long than necessary. Typing out such commands can become time-consuming and inefficient, especially if you regularly use the command. That’s where command aliases come into play

Zsh Aliases

ZSH aliases are configuration ~/.zshrc . The general syntax for the ZSH alias is
1alias <flag> <alias_name>="<command>"

Git Aliases

1alias gs="git status"
2alias ga="git add"
3alias gpl="git pull"
4alias gph="git push"

Completion

1autoload -Uz compinit && compinit

ZSH Plugin Manager

Zinit is a flexible and fast Zshell plugin manager that will allow you to install everything from GitHub and other sites.
  • Installation zinit
1# .zshrc
2ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
3# Download Zinit, if it's not there yet
4if [ ! -d "$ZINIT_HOME" ]; then
5  mkdir -p "$(dirname $ZINIT_HOME)"
6  git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
7fi
Install plugins
1zinit light <plugin-name>
2
3# example 
4
5# install ohmyzsh
6zinit light ohmyzsh/ohmyzsh
7
8# install p10k theme
9zinit ice depth=1; zinit light romkatv/powerlevel10k
10
11# install 
12zinit light zsh-users/zsh-completions
13zinit light zsh-users/zsh-autosuggestions
14zinit light zsh-users/zsh-syntax-highlighting
15zinit light agkozak/zsh-z