DEV Community

Larry
Larry

Posted on

2 1

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay