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)

18 Useful Github Repositories Every Developer Should Bookmark

18 Useful GitHub repositories every developer should bookmark: everything from learning resources and roadmaps to best practices, system designs, and tools.