- Open terminal
- Write there
open ~/.zshrc
- If file do not exist write
touch ~/.zshrc
andopen ~/.zshrc
again - Insert code below
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
setopt PROMPT_SUBST
export PROMPT='%{%B%F{38}%}[%D{%H:%M:%S}]%{%f%b%} %{%B%F{135}%}%~%{%f%b%} %{%B%F{156}%}$(parse_git_branch)%{%f%b%} %{%F{normal}%}=)%{%f%} '
TMOUT=1
TRAPALRM() {
zle reset-prompt
}
- Makes your PROMPT colored.
- Build PROMPT line that consist of realtime-clock, working directory and git branch.
- You should follow
%{%B%F{38}%}[%D{%H:%M:%S}]%{%f%b%}
structure, so string will be correctly parsed. - F - means Color. B - means Bold. S - means BGColor.
- Remove something like
"terminal.integrated.defaultProfile.osx": "bash"
from your VSCodesettings.json
to enable ZSH there. - Set ZSH as default editor:
chsh -s $(which zsh)
%{%B%F{135}%}%~%{%f%b%}
=>~
- means directory path. Putc
instead~
to show only folder.- 38, 135 and 156 are colors. You can change it depending on your preferences using palette below.