macOS Catalina uses zsh as the new default shell (instead of bash) in Terminal. This means that many people will be looking to re-setup their CLI with ~/.zshrc
instead of ~/.bash_profile
.
While customizing my .zshrc was a hassle, it was also an opportunity to clean up my profile and remove legacy settings.
Zsh offers an optional right side prompt, but I only used the left side prompt for now.
Here are some misc tips that I’ve found helpful:
- For basic PS1 exports (time/date, current dir, user, etc), you can find examples here. Things like
%D
for the current date,%~
for the current directoy, and more. - In your PS1 export, you can start color formatting with
%F{117}
and end color formatting with%f
. Replace 117 with whatever color your desire. You can find color codes here. - You can make your tab auto completion case insensitive (ignore case) by adding:
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}'
autoload -Uz compinit && compinit -i - You can show your current git branch with:
autoload -Uz vcs_info
precmd() { vcs_info }
zstyle ':vcs_info:git:*' formats '(%b)'
setopt prompt_subst
Note: you also need to add$vcs_info_msg_0_
in your PS1 export line.
I’ve thought about creating a zshrc WYSIWYG tool, ala Halloween Bash, but I’ve shelved those plans since there’s only so much time in a day. With macOS Catalina inevitable for macOS users, more and more people are going to be looking for easy ~/.zshrc
customization.