CLI Part 1: Base Zsh Setup
Why Zsh?
- sane, easy extensibility (plugins basically work like npm modules/package.json)
- flexible prompts (able to have multiline prompt and make use of right side of screen, OSS theme frameworks)
Also, zsh is now the default on MacOS since Catalina.
Change shell to zsh (if needed)
Note: zsh should already be the default on Mac OS >= Catalina, so you can skip this step.
# if needed install the 'zsh' package with your package manager
$ chsh -s $(which zsh)
Make sure to exit and start a new session.
Zinit
Zinit is easily the cleanest and fastest shell plugin manager I’ve come across.
From the repo:
Ultra-flexible and fast Zsh plugin manager with clean fpath, reports, completion management, Turbo, annexes, services, packages.
Installing Zinit
Clone zinit into ~/.zinit
$ mkdir ~/.zinit && git clone https://github.com/zdharma/zinit.git ~/.zinit/bin
Init ~/.zshrc
Edit your ~/.zshrc
in your preferred editor and these lines at the top:
Note: These lines should always be the first lines in your zshrc.
source ~/.zinit/bin/zinit.zsh
# enable completions
autoload -Uz compinit && compinit -du
autoload -U bashcompinit && bashcompinit # support bash completions
Finalize Zinit setup
Run the self-update
$ zinit self-update
Prettify
Powerlevel10k is a great prompt framework that provides easy, interactive configuration out of the box.
Add to your ~/.zshrc:
# theme framework
zplugin light "romkatv/powerlevel10k"
Load your zshrc again to install: $ source ~/.zshrc
Then just follow the interactive configuration menus to setup how you like, or feel free to run it later with p10k configure