mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
vcs: add vcs_info support in lib/vcs.zsh
lib/git.zsh isn't generic enough for me, and zsh provides vcs_info so we may as well use it.
This commit is contained in:
parent
4fadc30247
commit
574a615ec4
2 changed files with 31 additions and 1 deletions
|
|
@ -31,8 +31,14 @@ ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
|||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||
|
||||
# vcs theming default: Variables for theming the vcs info prompt
|
||||
ZSH_THEME_VCS_PROMPT_PREFIX=""
|
||||
ZSH_THEME_VCS_PROMPT_SUFFIX=""
|
||||
ZSH_THEME_VCS_PROMPT_STAGED="!"
|
||||
ZSH_THEME_VCS_PROMPT_UNSTAGED="*"
|
||||
|
||||
# Setup the prompt with pretty colors
|
||||
setopt prompt_subst
|
||||
|
||||
# Load the theme
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
||||
|
|
|
|||
24
lib/vcs.zsh
Normal file
24
lib/vcs.zsh
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
autoload -Uz vcs_info
|
||||
|
||||
VCS_BRANCH="%b%u%c"
|
||||
VCS_ACTION="%a"
|
||||
|
||||
zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${ZSH_THEME_VCS_PROMPT_UNSTAGED}"
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${ZSH_THEME_VCS_PROMPT_STAGED}"
|
||||
zstyle ':vcs_info:*:prompt:*' actionformats "${VCS_BRANCH}:${VCS_ACTION}" ""
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${VCS_BRANCH}" ""
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats "" ""
|
||||
|
||||
function vcs_info_prompt()
|
||||
{
|
||||
vcs_info prompt
|
||||
case $vcs_info_msg_0_ in
|
||||
"")
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo "$ZSH_THEME_VCS_PROMPT_PREFIX${vcs_info_msg_0_}$ZSH_THEME_VCS_PROMPT_SUFFIX"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue