mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-23 23:51:58 +00:00
Merge pull request #214 from dritter/fix_vcs_foreground_color
Allowing VCS Foreground Color to be over-rideable.
This commit is contained in:
commit
2260b83c98
2 changed files with 25 additions and 20 deletions
|
@ -18,7 +18,7 @@ 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' && \
|
||||||
-n $(git status ${FLAGS} | grep -E '^??' 2> /dev/null | tail -n1) ]]; then
|
-n $(git status ${FLAGS} | grep -E '^??' 2> /dev/null | tail -n1) ]]; then
|
||||||
hook_com[unstaged]+=" %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_UNTRACKED_ICON')%f"
|
hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
|
||||||
VCS_WORKDIR_HALF_DIRTY=true
|
VCS_WORKDIR_HALF_DIRTY=true
|
||||||
else
|
else
|
||||||
VCS_WORKDIR_HALF_DIRTY=false
|
VCS_WORKDIR_HALF_DIRTY=false
|
||||||
|
@ -34,12 +34,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)
|
ahead=$(git rev-list "${branch_name}"@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||||
(( ahead )) && gitstatus+=( " %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}%f" )
|
(( ahead )) && gitstatus+=( " $(print_icon 'VCS_OUTGOING_CHANGES_ICON')${ahead// /}" )
|
||||||
|
|
||||||
# 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)
|
behind=$(git rev-list HEAD.."${branch_name}"@{upstream} 2>/dev/null | wc -l)
|
||||||
(( behind )) && gitstatus+=( " %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}%f" )
|
(( behind )) && gitstatus+=( " $(print_icon 'VCS_INCOMING_CHANGES_ICON')${behind// /}" )
|
||||||
|
|
||||||
hook_com[misc]+=${(j::)gitstatus}
|
hook_com[misc]+=${(j::)gitstatus}
|
||||||
}
|
}
|
||||||
|
@ -51,12 +51,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{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}%f"
|
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
|
||||||
# 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{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_REMOTE_BRANCH_ICON')%f%F{$POWERLEVEL9K_VCS_FOREGROUND}${remote// /}%f"
|
hook_com[branch]+="$(print_icon 'VCS_REMOTE_BRANCH_ICON')${remote// /}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,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{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_TAG_ICON')${tag}%f"
|
[[ -n "${tag}" ]] && hook_com[branch]="$(print_icon 'VCS_TAG_ICON')${tag}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show count of stashed changes
|
# Show count of stashed changes
|
||||||
|
@ -74,13 +74,13 @@ 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{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_STASH_ICON')${stashes// /}%f"
|
hook_com[misc]+=" $(print_icon 'VCS_STASH_ICON')${stashes// /}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function +vi-hg-bookmarks() {
|
function +vi-hg-bookmarks() {
|
||||||
if [[ -n "${hgbmarks[@]}" ]]; then
|
if [[ -n "${hgbmarks[@]}" ]]; then
|
||||||
hook_com[hg-bookmark-string]=" %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}%f"
|
hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}"
|
||||||
|
|
||||||
# To signal that we want to use the sting we just generated, set the special
|
# To signal that we want to use the sting we just generated, set the special
|
||||||
# variable `ret' to something other than the default zero:
|
# variable `ret' to something other than the default zero:
|
||||||
|
|
|
@ -92,16 +92,11 @@ source $script_location/functions/vcs.zsh
|
||||||
if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then
|
if [[ "$POWERLEVEL9K_COLOR_SCHEME" == "light" ]]; then
|
||||||
DEFAULT_COLOR=white
|
DEFAULT_COLOR=white
|
||||||
DEFAULT_COLOR_INVERTED=black
|
DEFAULT_COLOR_INVERTED=black
|
||||||
DEFAULT_COLOR_DARK="252"
|
|
||||||
else
|
else
|
||||||
DEFAULT_COLOR=black
|
DEFAULT_COLOR=black
|
||||||
DEFAULT_COLOR_INVERTED=white
|
DEFAULT_COLOR_INVERTED=white
|
||||||
DEFAULT_COLOR_DARK="236"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_default POWERLEVEL9K_VCS_FOREGROUND "$DEFAULT_COLOR"
|
|
||||||
set_default POWERLEVEL9K_VCS_DARK_FOREGROUND "$DEFAULT_COLOR_DARK"
|
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Prompt Segment Constructors
|
# Prompt Segment Constructors
|
||||||
#
|
#
|
||||||
|
@ -760,6 +755,15 @@ prompt_vcs() {
|
||||||
VCS_WORKDIR_DIRTY=false
|
VCS_WORKDIR_DIRTY=false
|
||||||
VCS_WORKDIR_HALF_DIRTY=false
|
VCS_WORKDIR_HALF_DIRTY=false
|
||||||
|
|
||||||
|
# The vcs segment can have three different states - defaults to ''.
|
||||||
|
local current_state=""
|
||||||
|
typeset -AH vcs_states
|
||||||
|
vcs_states=(
|
||||||
|
'' 'green'
|
||||||
|
'modified' 'red'
|
||||||
|
'untracked' 'yellow'
|
||||||
|
)
|
||||||
|
|
||||||
VCS_CHANGESET_PREFIX=''
|
VCS_CHANGESET_PREFIX=''
|
||||||
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
|
if [[ "$POWERLEVEL9K_SHOW_CHANGESET" == true ]]; then
|
||||||
# Default: Just display the first 12 characters of our changeset-ID.
|
# Default: Just display the first 12 characters of our changeset-ID.
|
||||||
|
@ -768,19 +772,19 @@ prompt_vcs() {
|
||||||
VCS_CHANGESET_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH"
|
VCS_CHANGESET_HASH_LENGTH="$POWERLEVEL9K_CHANGESET_HASH_LENGTH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VCS_CHANGESET_PREFIX="%F{$POWERLEVEL9K_VCS_DARK_FOREGROUND}$(print_icon 'VCS_COMMIT_ICON')%0.$VCS_CHANGESET_HASH_LENGTH""i%f "
|
VCS_CHANGESET_PREFIX="$(print_icon 'VCS_COMMIT_ICON')%0.$VCS_CHANGESET_HASH_LENGTH""i "
|
||||||
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
|
||||||
|
|
||||||
VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%F{$POWERLEVEL9K_VCS_FOREGROUND}%b%c%u%m%f"
|
VCS_DEFAULT_FORMAT="$VCS_CHANGESET_PREFIX%b%c%u%m"
|
||||||
zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT"
|
zstyle ':vcs_info:*' formats "$VCS_DEFAULT_FORMAT"
|
||||||
|
|
||||||
zstyle ':vcs_info:*' actionformats "%b %F{red}| %a%f"
|
zstyle ':vcs_info:*' actionformats "%b %F{red}| %a%f"
|
||||||
|
|
||||||
zstyle ':vcs_info:*' stagedstr " %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_STAGED_ICON')%f"
|
zstyle ':vcs_info:*' stagedstr " $(print_icon 'VCS_STAGED_ICON')"
|
||||||
zstyle ':vcs_info:*' unstagedstr " %F{$POWERLEVEL9K_VCS_FOREGROUND}$(print_icon 'VCS_UNSTAGED_ICON')%f"
|
zstyle ':vcs_info:*' unstagedstr " $(print_icon 'VCS_UNSTAGED_ICON')"
|
||||||
|
|
||||||
defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)
|
defined POWERLEVEL9K_VCS_GIT_HOOKS || POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind git-stash git-remotebranch git-tagname)
|
||||||
zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS
|
zstyle ':vcs_info:git*+set-message:*' hooks $POWERLEVEL9K_VCS_GIT_HOOKS
|
||||||
|
@ -806,14 +810,15 @@ prompt_vcs() {
|
||||||
if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then
|
if [[ "$VCS_WORKDIR_DIRTY" == true ]]; then
|
||||||
# $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh,
|
# $vcs_visual_identifier gets set in +vi-vcs-detect-changes in functions/vcs.zsh,
|
||||||
# as we have there access to vcs_info internal hooks.
|
# as we have there access to vcs_info internal hooks.
|
||||||
"$1_prompt_segment" "$0_MODIFIED" "$2" "red" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
current_state='modified'
|
||||||
else
|
else
|
||||||
if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then
|
if [[ "$VCS_WORKDIR_HALF_DIRTY" == true ]]; then
|
||||||
"$1_prompt_segment" "$0_UNTRACKED" "$2" "yellow" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
current_state='untracked'
|
||||||
else
|
else
|
||||||
"$1_prompt_segment" "$0" "$2" "green" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
current_state=''
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
"$1_prompt_segment" "${0}_${(U)current_state}" "$2" "${vcs_states[$current_state]}" "$DEFAULT_COLOR" "$vcs_prompt" "$vcs_visual_identifier"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue