allow configuring the delimiters in my_git_formatter

Signed-off-by: Luis Davim <luis.davim@jet.com>
This commit is contained in:
Luis Davim 2020-02-10 11:56:41 +00:00
parent 54360ed430
commit 518b641ff4
4 changed files with 81 additions and 40 deletions

View File

@ -385,6 +385,11 @@
local conflicted='%244F' # grey foreground local conflicted='%244F' # grey foreground
fi fi
# Delemitors
local sep="${base} "
local start="${base} "
local finish="${base} "
local res local res
local where # branch or tag local where # branch or tag
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
@ -409,32 +414,37 @@
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
fi fi
# Show if the local branch is not tracking any remote branch.
if [[ -z ${VCS_STATUS_REMOTE_BRANCH} ]]; then
res+="${meta}:${clean}L" # escape %
fi
# ⇣42 if behind the remote. # ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_COMMITS_BEHIND}" (( VCS_STATUS_COMMITS_BEHIND )) && res+="${sep}${clean}${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.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=${sep}
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}" (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}"
# ⇠42 if behind the push remote. # ⇠42 if behind the push remote.
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+="${sep}"
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}" (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}"
# *42 if have stashes. # *42 if have stashes.
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" (( VCS_STATUS_STASHES )) && res+="${sep}${clean}*${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state. # 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" [[ -n $VCS_STATUS_ACTION ]] && res+="${sep}${conflicted}${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts. # ~42 if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" (( VCS_STATUS_NUM_CONFLICTED )) && res+="${sep}${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes. # +42 if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" (( VCS_STATUS_NUM_STAGED )) && res+="${sep}${staged}+${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes. # !42 if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" (( VCS_STATUS_NUM_UNSTAGED )) && res+="${sep}${modified}!${VCS_STATUS_NUM_UNSTAGED}"
# ?42 if have untracked files. It's really a question mark, your font isn't broken. # ?42 if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all. # Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" (( VCS_STATUS_NUM_UNTRACKED )) && res+="${sep}${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
typeset -g my_git_format=$res typeset -g my_git_format="${start}${res}${finish}"
} }
functions -M my_git_formatter 2>/dev/null functions -M my_git_formatter 2>/dev/null

View File

@ -386,6 +386,11 @@
local conflicted='%f' # default foreground local conflicted='%f' # default foreground
fi fi
# Delemitors
local sep="${base}|"
local start="${base}("
local finish="${base})"
local res local res
local where # branch or tag local where # branch or tag
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
@ -410,32 +415,37 @@
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
fi fi
# Show if the local branch is not tracking any remote branch.
if [[ -z ${VCS_STATUS_REMOTE_BRANCH} ]]; then
res+="${meta}:${clean}L" # escape %
fi
# ⇣42 if behind the remote. # ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_COMMITS_BEHIND}" (( VCS_STATUS_COMMITS_BEHIND )) && res+="${sep}${clean}${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.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=${sep}
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}" (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}"
# ⇠42 if behind the push remote. # ⇠42 if behind the push remote.
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+="${sep}"
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}" (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}"
# *42 if have stashes. # *42 if have stashes.
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" (( VCS_STATUS_STASHES )) && res+="${sep}${clean}*${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state. # 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" [[ -n $VCS_STATUS_ACTION ]] && res+="${sep}${conflicted}${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts. # ~42 if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" (( VCS_STATUS_NUM_CONFLICTED )) && res+="${sep}${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes. # +42 if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" (( VCS_STATUS_NUM_STAGED )) && res+="${sep}${staged}+${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes. # !42 if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" (( VCS_STATUS_NUM_UNSTAGED )) && res+="${sep}${modified}!${VCS_STATUS_NUM_UNSTAGED}"
# ?42 if have untracked files. It's really a question mark, your font isn't broken. # ?42 if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all. # Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" (( VCS_STATUS_NUM_UNTRACKED )) && res+="${sep}${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
typeset -g my_git_format=$res typeset -g my_git_format="${start}${res}${finish}"
} }
functions -M my_git_formatter 2>/dev/null functions -M my_git_formatter 2>/dev/null

View File

@ -386,6 +386,11 @@
local conflicted='%244F' # grey foreground local conflicted='%244F' # grey foreground
fi fi
# Delemitors
local sep="${base}|"
local start="${base}("
local finish="${base})"
local res local res
local where # branch or tag local where # branch or tag
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
@ -410,32 +415,38 @@
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
fi fi
# Show if the local branch is not tracking any remote branch.
if [[ -z ${VCS_STATUS_REMOTE_BRANCH} ]]; then
res+="${meta}:${clean}L" # escape %
fi
# ⇣42 if behind the remote. # ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_COMMITS_BEHIND}" (( VCS_STATUS_COMMITS_BEHIND )) && res+="${sep}${clean}${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.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=${sep}
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}" (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}"
# ⇠42 if behind the push remote. # ⇠42 if behind the push remote.
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+="${sep}"
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}" (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}"
# *42 if have stashes. # *42 if have stashes.
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" (( VCS_STATUS_STASHES )) && res+="${sep}${clean}*${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state. # 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" [[ -n $VCS_STATUS_ACTION ]] && res+="${sep}${conflicted}${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts. # ~42 if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" (( VCS_STATUS_NUM_CONFLICTED )) && res+="${sep}${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes. # +42 if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" (( VCS_STATUS_NUM_STAGED )) && res+="${sep}${staged}+${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes. # !42 if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" (( VCS_STATUS_NUM_UNSTAGED )) && res+="${sep}${modified}!${VCS_STATUS_NUM_UNSTAGED}"
# ?42 if have untracked files. It's really a question mark, your font isn't broken. # ?42 if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all. # Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" (( VCS_STATUS_NUM_UNTRACKED )) && res+="${sep}${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
typeset -g my_git_format="${start}${res}${finish}"
typeset -g my_git_format=$res
} }
functions -M my_git_formatter 2>/dev/null functions -M my_git_formatter 2>/dev/null

View File

@ -389,6 +389,11 @@
local untracked='%0F' # black foreground local untracked='%0F' # black foreground
local conflicted='%1F' # red foreground local conflicted='%1F' # red foreground
# Delemitors
local sep="${base}|"
local start="${base}("
local finish="${base})"
local res local res
local where # branch or tag local where # branch or tag
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
@ -413,32 +418,37 @@
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
fi fi
# Show if the local branch is not tracking any remote branch.
if [[ -z ${VCS_STATUS_REMOTE_BRANCH} ]]; then
res+="${meta}:${clean}L" # escape %
fi
# ⇣42 if behind the remote. # ⇣42 if behind the remote.
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_COMMITS_BEHIND}" (( VCS_STATUS_COMMITS_BEHIND )) && res+="${sep}${clean}${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.
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=${sep}
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}" (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_COMMITS_AHEAD}"
# ⇠42 if behind the push remote. # ⇠42 if behind the push remote.
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+="${sep}"
# ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}" (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}${VCS_STATUS_PUSH_COMMITS_AHEAD}"
# *42 if have stashes. # *42 if have stashes.
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" (( VCS_STATUS_STASHES )) && res+="${sep}${clean}*${VCS_STATUS_STASHES}"
# 'merge' if the repo is in an unusual state. # 'merge' if the repo is in an unusual state.
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" [[ -n $VCS_STATUS_ACTION ]] && res+="${sep}${conflicted}${VCS_STATUS_ACTION}"
# ~42 if have merge conflicts. # ~42 if have merge conflicts.
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" (( VCS_STATUS_NUM_CONFLICTED )) && res+="${sep}${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
# +42 if have staged changes. # +42 if have staged changes.
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" (( VCS_STATUS_NUM_STAGED )) && res+="${sep}${staged}+${VCS_STATUS_NUM_STAGED}"
# !42 if have unstaged changes. # !42 if have unstaged changes.
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" (( VCS_STATUS_NUM_UNSTAGED )) && res+="${sep}${modified}!${VCS_STATUS_NUM_UNSTAGED}"
# ?42 if have untracked files. It's really a question mark, your font isn't broken. # ?42 if have untracked files. It's really a question mark, your font isn't broken.
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
# Remove the next line if you don't want to see untracked files at all. # Remove the next line if you don't want to see untracked files at all.
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" (( VCS_STATUS_NUM_UNTRACKED )) && res+="${sep}${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
typeset -g my_git_format=$res typeset -g my_git_format="${start}${res}${finish}"
} }
functions -M my_git_formatter 2>/dev/null functions -M my_git_formatter 2>/dev/null