Last active
October 15, 2024 01:10
-
-
Save chrisnolet/d3582cd63eb3d7b4fcb4d5975fd91d04 to your computer and use it in GitHub Desktop.
Color-coded git branch for zsh prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ %# ' |
Thank you. Works great!
Thank you ❤️
Thank you!
Thank you!
thx!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's exactly what I was looking for