From 2ff8332d2de4959c38c627a3f57f28bdb7d2387e Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 8 Jul 2019 16:54:26 +0200 Subject: [PATCH] add POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING --- internal/p10k.zsh | 48 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 29077001..85100dc9 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1718,17 +1718,22 @@ typeset -gAH _P9K_GIT_SLOW function _p9k_vcs_status_save() { local z=$'\0' - _P9K_LAST_GIT_PROMPT[$VCS_STATUS_WORKDIR]=$VCS_STATUS_COMMIT$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_REMOTE_BRANCH\ -$z$VCS_STATUS_REMOTE_URL$z$VCS_STATUS_ACTION$z$VCS_STATUS_NUM_STAGED$z$VCS_STATUS_NUM_UNSTAGED\ -$z$VCS_STATUS_NUM_UNTRACKED$z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\ -$z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG + _P9K_LAST_GIT_PROMPT[$VCS_STATUS_WORKDIR]=$VCS_STATUS_ACTION$z$VCS_STATUS_COMMIT\ +$z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z$VCS_STATUS_HAS_CONFLICTED\ +$z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\ +$z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\ +$z$VCS_STATUS_NUM_STAGED$z$VCS_STATUS_NUM_UNSTAGED$z$VCS_STATUS_NUM_UNTRACKED\ +$z$VCS_STATUS_REMOTE_BRANCH$z$VCS_STATUS_REMOTE_NAME$z$VCS_STATUS_REMOTE_URL\ +$z$VCS_STATUS_RESULT$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG } function _p9k_vcs_status_restore() { - for VCS_STATUS_COMMIT VCS_STATUS_LOCAL_BRANCH VCS_STATUS_REMOTE_BRANCH \ - VCS_STATUS_REMOTE_URL VCS_STATUS_ACTION VCS_STATUS_NUM_STAGED VCS_STATUS_NUM_UNSTAGED \ - VCS_STATUS_NUM_UNTRACKED VCS_STATUS_HAS_STAGED VCS_STATUS_HAS_UNSTAGED VCS_STATUS_HAS_UNTRACKED \ - VCS_STATUS_COMMITS_AHEAD VCS_STATUS_COMMITS_BEHIND VCS_STATUS_STASHES VCS_STATUS_TAG \ + for VCS_STATUS_ACTION VCS_STATUS_COMMIT VCS_STATUS_COMMITS_AHEAD VCS_STATUS_COMMITS_BEHIND \ + VCS_STATUS_HAS_CONFLICTED VCS_STATUS_HAS_STAGED VCS_STATUS_HAS_UNSTAGED \ + VCS_STATUS_HAS_UNTRACKED VCS_STATUS_INDEX_SIZE VCS_STATUS_LOCAL_BRANCH \ + VCS_STATUS_NUM_CONFLICTED VCS_STATUS_NUM_STAGED VCS_STATUS_NUM_UNSTAGED \ + VCS_STATUS_NUM_UNTRACKED VCS_STATUS_REMOTE_BRANCH VCS_STATUS_REMOTE_NAME \ + VCS_STATUS_REMOTE_URL VCS_STATUS_RESULT VCS_STATUS_STASHES VCS_STATUS_TAG \ in "${(@0)1}"; do done } @@ -1752,6 +1757,18 @@ function _p9k_vcs_status_purge() { done } +function _p9k_vcs_icon() { + case "$VCS_STATUS_REMOTE_URL" in + *github*) _P9K_RETVAL=VCS_GIT_GITHUB_ICON;; + *bitbucket*) _P9K_RETVAL=VCS_GIT_BITBUCKET_ICON;; + *stash*) _P9K_RETVAL=VCS_GIT_GITHUB_ICON;; + *gitlab*) _P9K_RETVAL=VCS_GIT_GITLAB_ICON;; + *) _P9K_RETVAL=VCS_GIT_ICON;; + esac +} + +set_default POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING false + function _p9k_vcs_render() { local state @@ -1769,6 +1786,21 @@ function _p9k_vcs_render() { return 1 fi + if [[ $POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING == true ]]; then + if [[ -z $state ]]; then + if [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then + state=MODIFIED + elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then + state=UNTRACKED + else + state=CLEAN + fi + fi + _p9k_vcs_icon + $1_prompt_segment prompt_vcs_$state $2 "${vcs_states[$state]}" "$DEFAULT_COLOR" "$_P9K_RETVAL" 0 '' "" + return 0 + fi + (( ${POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-untracked]} )) || VCS_STATUS_HAS_UNTRACKED=0 (( ${POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-aheadbehind]} )) || { VCS_STATUS_COMMITS_AHEAD=0 && VCS_STATUS_COMMITS_BEHIND=0 } (( ${POWERLEVEL9K_VCS_GIT_HOOKS[(I)git-stash]} )) || VCS_STATUS_STASHES=0