DEV Community

Larry
Larry

Posted on

customize your zsh

Alt customize zsh

When someone wants to customize own mac zsh terminal and use color for each text also wants to show git branch name then you can add below code in your .zshrc

# Git branch in prompt.
parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}

setopt PROMPT_SUBST
export PROMPT='%F{cyan}%n@%M:~ %F{yellow}%. %F{green}$(parse_git_branch)%f %F{normal}$%f '
Enter fullscreen mode Exit fullscreen mode

Here,
%n => mac username
%M => mac computer name
%. => current folder name
$(parse_git_branch)%f => git branch name (if working in git repo)

Top comments (0)