shorten git branch name if over 32 chars long; tune colors

pull/186/head
romkatv 5 years ago
parent d68bd813ae
commit 4ba78dc2be

@ -156,9 +156,9 @@ fi
typeset -g POWERLEVEL9K_BACKGROUND=238 typeset -g POWERLEVEL9K_BACKGROUND=238
# Separator between same-color segments on the left. # Separator between same-color segments on the left.
typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%244F\uE0B1' typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%246F\uE0B1'
# Separator between same-color segments on the right. # Separator between same-color segments on the right.
typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%244F\uE0B3' typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%246F\uE0B3'
# Separator between different-color segments on the left. # Separator between different-color segments on the left.
typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0'
# Separator between different-color segments on the right. # Separator between different-color segments on the right.
@ -288,13 +288,18 @@ fi
# VCS_STATUS parameters are set by gitstatus plugin. See reference: # VCS_STATUS parameters are set by gitstatus plugin. See reference:
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
local vcs='' local vcs=''
# 'feature' or '@72f5c8a' if not on a branch. # If on a branch...
vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}
vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # If branch name is at most 32 characters long, show it in full.
vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
# If branch name is over 32 characters long, show the first 12 … the last 12.
vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}'
# '@72f5c8a' if not on a branch.
vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}'
# ':master' if the tracking branch name differs from local branch. # ':master' if the tracking branch name differs from local branch.
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%248F:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
# '#tag' if on a tag. # '#tag' if on a tag.
vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' vcs+='${VCS_STATUS_TAG:+%248F#%76F${VCS_STATUS_TAG//\%/%%}}'
# ⇣42 if behind the remote. # ⇣42 if behind the remote.
vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}'
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
@ -323,7 +328,6 @@ fi
typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs
# When Git status is being refreshed asynchronously, display the last known repo status in grey. # When Git status is being refreshed asynchronously, display the last known repo status in grey.
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F}
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244
# Enable counters for staged, unstaged, etc. # Enable counters for staged, unstaged, etc.
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
@ -339,6 +343,7 @@ fi
# isn't in an svn or hg reposotiry. # isn't in an svn or hg reposotiry.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=246
# These settings are used for respositories other than Git or when gitstatusd fails and # These settings are used for respositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info. # Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76

@ -271,8 +271,13 @@ fi
# VCS_STATUS parameters are set by gitstatus plugin. See reference: # VCS_STATUS parameters are set by gitstatus plugin. See reference:
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
local vcs='' local vcs=''
# 'feature' or '@72f5c8a' if not on a branch. # If on a branch...
vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}
# If local branch name is at most 32 characters long, show it in full.
vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}'
# If local branch name is over 32 characters long, show the first 12 … the last 12.
vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}'
# '@72f5c8a' if not on a branch.
vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}'
# ':master' if the tracking branch name differs from local branch. # ':master' if the tracking branch name differs from local branch.
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
@ -306,7 +311,6 @@ fi
typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs
# When Git status is being refreshed asynchronously, display the last known repo status in grey. # When Git status is being refreshed asynchronously, display the last known repo status in grey.
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F}
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244
# Enable counters for staged, unstaged, etc. # Enable counters for staged, unstaged, etc.
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
@ -322,6 +326,7 @@ fi
# isn't in an svn or hg reposotiry. # isn't in an svn or hg reposotiry.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244
# These settings are used for respositories other than Git or when gitstatusd fails and # These settings are used for respositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info. # Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76

@ -894,6 +894,10 @@ function generate_config() {
lines=("${(@)lines/#(#b)([[:space:]]#)\# $1( |)/$match[1]$1$match[2]$match[2]}") lines=("${(@)lines/#(#b)([[:space:]]#)\# $1( |)/$match[1]$1$match[2]$match[2]}")
} }
function rep() {
lines=("${(@)lines//$1/$2}")
}
sub MODE $POWERLEVEL9K_MODE sub MODE $POWERLEVEL9K_MODE
if (( cap_narrow_icons )); then if (( cap_narrow_icons )); then
@ -936,6 +940,8 @@ function generate_config() {
sub LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$left_head'" sub LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$left_head'"
sub RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$right_head'" sub RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$right_head'"
sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$right_tail'" sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$right_tail'"
sub VCS_LOADING_FOREGROUND $sep_color[$color]
rep '%248F' "%$prefix_color[$color]F"
fi fi
if [[ -n ${(j::)extra_icons} ]]; then if [[ -n ${(j::)extra_icons} ]]; then

Loading…
Cancel
Save