summaryrefslogtreecommitdiff
path: root/functions/vcs.zsh
diff options
context:
space:
mode:
authorTaras Shpachenko <taras.shpachenko@onapp.com>2018-04-12 13:39:39 +0300
committerTaras Shpachenko <taras.shpachenko@onapp.com>2018-04-12 18:11:23 +0300
commit111d152d48cc92229cb523a992a0ecee740381e7 (patch)
tree7d6f348319ce3c6819b8a398c4ddfafa1a0773bd /functions/vcs.zsh
parent4c919f1a2bca9d52271edebcbd5090423304afef (diff)
Add vcs branch name truncating.
Diffstat (limited to 'functions/vcs.zsh')
-rwxr-xr-xfunctions/vcs.zsh15
1 files changed, 15 insertions, 0 deletions
diff --git a/functions/vcs.zsh b/functions/vcs.zsh
index e2e9f3a3..c936f27d 100755
--- a/functions/vcs.zsh
+++ b/functions/vcs.zsh
@@ -51,6 +51,21 @@ function +vi-git-remotebranch() {
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)
+ if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then
+ set_default POWERLEVEL9K_VCS_SHORTEN_DELIMITER $'\U2026'
+
+ if [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH ] && [ ${#hook_com[branch]} -gt $POWERLEVEL9K_VCS_SHORTEN_LENGTH ]; then
+ case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in
+ truncate_middle)
+ hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER$(echo "${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")"
+ ;;
+ truncate_from_right)
+ hook_com[branch]="$(echo "${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}")$POWERLEVEL9K_VCS_SHORTEN_DELIMITER"
+ ;;
+ esac
+ fi
+ fi
+
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
# Always show the remote
#if [[ -n ${remote} ]] ; then