My Zsh Config

My personal config for Zsh (Z Shell), noting for next time.

Installation

Windows

Helpful resources:

Linux

Use your favorite package manager to install zsh and then run chsh -s $(which zsh) to set Z Shell as your default shell.

Mac

It's installed by default.

Themes and Plugins

Firstly, install oh-my-zsh and powerlevel10k.

1
2
3
4
# installs oh-my-zsh using curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# clones powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Then, to set powerlevel10k as the theme, edit in ~/.zshrc:

1
ZSH_THEME="powerlevel10k/powerlevel10k"

Plugins

Oh-my-zsh provides many plugins (See the list), and you can install more by yourself.

I installed some plugins not provided by oh-my-zsh:

1
2
3
4
5
git clone https://github.com/esc/conda-zsh-completion ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/conda-zsh-completion
git clone https://github.com/sukkaw/zsh-osx-autoproxy ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-osx-autoproxy --depth=1 # ONLY on macOS
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions --depth=1
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search --depth=1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting --depth=1

Edit in ~/.zshrc:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
plugins=(
conda-zsh-completion
fd
fzf
git
git-commit
history-substring-search
pip
ripgrep
z
zsh-autosuggestions
zsh-osx-autoproxy
zsh-syntax-highlighting
)
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=white'

Usage of some plugins:

Alias Command
g git
ga git add
gaa git add --all
gapa git add --patch
gau git add --update
gav git add --verbose
gb git branch
gco git checkout
gcl git clone --recurse-submodules
gcam git commit --all --message
gc git commit --verbose
gc! git commit --verbose --amend
gd git diff
gf git fetch
glog git log --oneline --decorate --graph
gl git pull
gp git push
gst git status
gss git status --short
... ...

Syntax: git <type> [(-s, --scope) "<scope>"] "<message>", where <type> is:

  1. build
  2. chore
  3. ci
  4. docs
  5. feat
  6. fix
  7. perf
  8. refactor
  9. rev
  10. style
  11. test

NOTE: the alias for revert type is rev, as otherwise it conflicts with the git command of the same name.
It will still generate a commit message in the format revert: <message>

Alias Command
git style "remove trailing whitespace" git commit -m "style: remove trailing whitespace"
git fix -s "router" "correct redirect link" git commit -m "fix(router): correct redirect link"

Q&A

Resources