Better prompt
22nd August 2022
I've seen the fancy prompts with Oh My Zsh and have used them myself, but they're just too heavy for such a simple problem. Setting it all up identically on a new machine is also very tedious.
bash
# current git branch
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
zstyle ':vcs_info:git:*' formats ' [%b]'
# custom prompt: "<time> <curr_dir> <git_branch> <right_arrow>"
PROMPT='%F{5}%B%D{%l:%M%p}%b%f %B%F{4}%U%~%f%u%F{6}${vcs_info_msg_0_}%f %F{3}➜%f%b '
So here is my 9 lines. Add this to your ~/.zshrc
or similar. The colors may be different, so refer to a Xterm 256 color chart, and replace the numbers. Other options (date, username, hostname) are listed here in the zsh prompt documentation.