From 574a615ec4c49a8b9821daf730f64cb6a8f5454c Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Wed, 29 Dec 2010 11:56:51 +0000 Subject: [PATCH] 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. --- lib/appearance.zsh | 8 +++++++- lib/vcs.zsh | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 lib/vcs.zsh diff --git a/lib/appearance.zsh b/lib/appearance.zsh index ffee52b5e..258de7d69 100644 --- a/lib/appearance.zsh +++ b/lib/appearance.zsh @@ -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" \ No newline at end of file +source "$ZSH/themes/$ZSH_THEME.zsh-theme" diff --git a/lib/vcs.zsh b/lib/vcs.zsh new file mode 100644 index 000000000..a44abe5d5 --- /dev/null +++ b/lib/vcs.zsh @@ -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 +}