Skip to content

Instantly share code, notes, and snippets.

@chrisnolet
Last active April 13, 2024 06:13
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save chrisnolet/d3582cd63eb3d7b4fcb4d5975fd91d04 to your computer and use it in GitHub Desktop.
Save chrisnolet/d3582cd63eb3d7b4fcb4d5975fd91d04 to your computer and use it in GitHub Desktop.
Color-coded git branch for zsh prompt
autoload -Uz compinit && compinit
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
add-zsh-hook precmd vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats " %F{cyan}%c%u(%b)%f"
zstyle ':vcs_info:*' actionformats " %F{cyan}%c%u(%b)%f %a"
zstyle ':vcs_info:*' stagedstr "%F{green}"
zstyle ':vcs_info:*' unstagedstr "%F{red}"
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
+vi-git-untracked() {
if git --no-optional-locks status --porcelain 2> /dev/null | grep -q "^??"; then
hook_com[staged]+="%F{red}"
fi
}
setopt PROMPT_SUBST
export PROMPT='%n:%1~$vcs_info_msg_0_ %# '
@rbarner14
Copy link

Works nicely. Thanks!

@vladimircvetkovic77
Copy link

works

@shaba-imran
Copy link

very nice

@melissawang17LIVE
Copy link

thanks!

@alvarovaliente-s37
Copy link

Worked perfect! Thanks!

@vitorpbarbosa7
Copy link

Works, thank you so much !

@zhifengkoh
Copy link

Thank you!

@DirkLachowski
Copy link

Great, thanks

@radoslawmul-purestorage
Copy link

Love it, thanks

@MizterFrek
Copy link

It's exactly what I was looking for

@teenageorge
Copy link

Thank you. Works great!

@sluger
Copy link

sluger commented Mar 21, 2023

Thank you ❤️

@meltingmettle
Copy link

Thank you!

@clawrence2
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment