VCS-Info should be affected by foreground color settings of the user.

This commit is contained in:
Dominik Ritter 2015-05-23 00:09:30 +02:00
parent 04aa036e60
commit 3aba9e20e5
1 changed files with 25 additions and 12 deletions

View File

@ -70,6 +70,19 @@ else
DEFAULT_COLOR_DARK="236" DEFAULT_COLOR_DARK="236"
fi fi
# Unfortunately the foreground colors for the VCS segment have
# to be overwritten at this point.
# Overwrite given foreground-color by user defined variable for this segment.
local VCS_FOREGROUND_COLOR=$DEFAULT_COLOR
local VCS_FOREGROUND_USER_VARIABLE=POWERLEVEL9K_VCS_FOREGROUND
local VCS_FG_COLOR_MODIFIER=${(P)VCS_FOREGROUND_USER_VARIABLE}
[[ -n $VCS_FG_COLOR_MODIFIER ]] && VCS_FOREGROUND_COLOR=$VCS_FG_COLOR_MODIFIER
local VCS_FOREGROUND_COLOR_DARK=$DEFAULT_COLOR_DARK
local VCS_FOREGROUND_USER_VARIABLE_DARK=POWERLEVEL9K_VCS_DARK_FOREGROUND
local VCS_FG_DARK_COLOR_MODIFIER=${(P)VCS_FOREGROUND_USER_VARIABLE_DARK}
[[ -n $VCS_FG_DARK_COLOR_MODIFIER ]] && VCS_FOREGROUND_COLOR_DARK=$VCS_FG_DARK_COLOR_MODIFIER
################################################################ ################################################################
# VCS Information Settings # VCS Information Settings
################################################################ ################################################################
@ -86,17 +99,17 @@ if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
VCS_CHANGESET_HASH_LENGTH=$POWERLEVEL9K_CHANGESET_HASH_LENGTH VCS_CHANGESET_HASH_LENGTH=$POWERLEVEL9K_CHANGESET_HASH_LENGTH
fi fi
VCS_CHANGESET_PREFIX="%F{$DEFAULT_COLOR_DARK}%0.$VCS_CHANGESET_HASH_LENGTH""i@%f" VCS_CHANGESET_PREFIX="%F{$VCS_FOREGROUND_COLOR_DARK}%0.$VCS_CHANGESET_HASH_LENGTH""i@%f"
fi fi
zstyle ':vcs_info:*' enable git hg zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' formats " $VCS_CHANGESET_PREFIX%F{$DEFAULT_COLOR}%b%c%u%m%f" zstyle ':vcs_info:*' formats " $VCS_CHANGESET_PREFIX%F{$VCS_FOREGROUND_COLOR}%b%c%u%m%f"
zstyle ':vcs_info:*' actionformats " %b %F{red}| %a%f" zstyle ':vcs_info:*' actionformats " %b %F{red}| %a%f"
zstyle ':vcs_info:*' stagedstr " %F{$DEFAULT_COLOR}$VCS_STAGED_ICON%f" zstyle ':vcs_info:*' stagedstr " %F{$VCS_FOREGROUND_COLOR}$VCS_STAGED_ICON%f"
zstyle ':vcs_info:*' unstagedstr " %F{$DEFAULT_COLOR}$VCS_UNSTAGED_ICON%f" zstyle ':vcs_info:*' unstagedstr " %F{$VCS_FOREGROUND_COLOR}$VCS_UNSTAGED_ICON%f"
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-stash git-remotebranch git-tagname zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-stash git-remotebranch git-tagname
@ -198,14 +211,14 @@ prompt_vcs() {
$1_prompt_segment $0 green $DEFAULT_COLOR $1_prompt_segment $0 green $DEFAULT_COLOR
fi fi
echo -n "%F{$DEFAULT_COLOR}%f$vcs_prompt" echo -n "%F{$VCS_FOREGROUND_COLOR}%f$vcs_prompt"
fi fi
} }
function +vi-git-untracked() { function +vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \
$(git ls-files --others --exclude-standard | sed q | wc -l | tr -d ' ') != 0 ]]; then $(git ls-files --others --exclude-standard | sed q | wc -l | tr -d ' ') != 0 ]]; then
hook_com[unstaged]+=" %F{$DEFAULT_COLOR}?%f" hook_com[unstaged]+=" %F{$VCS_FOREGROUND_COLOR}?%f"
fi fi
} }
@ -218,12 +231,12 @@ function +vi-git-aheadbehind() {
# for git prior to 1.7 # for git prior to 1.7
# ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l) # ahead=$(git rev-list origin/${branch_name}..HEAD | wc -l)
ahead=$(git rev-list ${branch_name}@{upstream}..HEAD 2>/dev/null | wc -l | tr -d ' ') ahead=$(git rev-list ${branch_name}@{upstream}..HEAD 2>/dev/null | wc -l | tr -d ' ')
(( $ahead )) && gitstatus+=( " %F{$DEFAULT_COLOR}↑${ahead// /}%f" ) (( $ahead )) && gitstatus+=( " %F{$VCS_FOREGROUND_COLOR}↑${ahead// /}%f" )
# for git prior to 1.7 # for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${branch_name} | wc -l) # behind=$(git rev-list HEAD..origin/${branch_name} | wc -l)
behind=$(git rev-list HEAD..${branch_name}@{upstream} 2>/dev/null | wc -l | tr -d ' ') behind=$(git rev-list HEAD..${branch_name}@{upstream} 2>/dev/null | wc -l | tr -d ' ')
(( $behind )) && gitstatus+=( " %F{$DEFAULT_COLOR}↓${behind// /}%f" ) (( $behind )) && gitstatus+=( " %F{$VCS_FOREGROUND_COLOR}↓${behind// /}%f" )
hook_com[misc]+=${(j::)gitstatus} hook_com[misc]+=${(j::)gitstatus}
} }
@ -235,12 +248,12 @@ function +vi-git-remotebranch() {
remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/} remote=${$(git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/}
branch_name=${$(git symbolic-ref --short HEAD 2>/dev/null)} branch_name=${$(git symbolic-ref --short HEAD 2>/dev/null)}
hook_com[branch]="%F{$DEFAULT_COLOR}${hook_com[branch]}%f" hook_com[branch]="%F{$VCS_FOREGROUND_COLOR}${hook_com[branch]}%f"
# Always show the remote # Always show the remote
#if [[ -n ${remote} ]] ; then #if [[ -n ${remote} ]] ; then
# Only show the remote if it differs from the local # Only show the remote if it differs from the local
if [[ -n ${remote} && ${remote#*/} != ${branch_name} ]] ; then if [[ -n ${remote} && ${remote#*/} != ${branch_name} ]] ; then
hook_com[branch]+="%F{$DEFAULT_COLOR}→%f%F{$DEFAULT_COLOR}${remote// /}%f" hook_com[branch]+="%F{$VCS_FOREGROUND_COLOR}→%f%F{$VCS_FOREGROUND_COLOR}${remote// /}%f"
fi fi
} }
@ -248,7 +261,7 @@ function +vi-git-tagname() {
local tag local tag
tag=$(git describe --tags --exact-match HEAD 2>/dev/null) tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
[[ -n ${tag} ]] && hook_com[branch]=" %F{$DEFAULT_COLOR}${tag}%f" [[ -n ${tag} ]] && hook_com[branch]=" %F{$VCS_FOREGROUND_COLOR}${tag}%f"
} }
# Show count of stashed changes # Show count of stashed changes
@ -258,7 +271,7 @@ function +vi-git-stash() {
if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then if [[ -s $(git rev-parse --git-dir)/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l) stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" %F{$DEFAULT_COLOR}⍟${stashes// /}%f" hook_com[misc]+=" %F{$VCS_FOREGROUND_COLOR}⍟${stashes// /}%f"
fi fi
} }