diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index d48bc21..2928bae 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -379,29 +379,37 @@ fi local res - local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" - where=${(V)VCS_STATUS_LOCAL_BRANCH} - elif [[ -n $VCS_STATUS_TAG ]]; then - res+="${meta}#" - where=${(V)VCS_STATUS_TAG} + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" fi - # If local branch name or tag is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#where > 32 )) && where[13,-13]="…" + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi - res+="${clean}${where//\%/%%}" # escape % - - # Display the current Git commit if there is no branch or tag. - # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. - [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi # ⇣42 if behind the remote. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index 34eac1f..9a6e286 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -377,29 +377,37 @@ fi local res - local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" - where=${(V)VCS_STATUS_LOCAL_BRANCH} - elif [[ -n $VCS_STATUS_TAG ]]; then - res+="${meta}#" - where=${(V)VCS_STATUS_TAG} + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" fi - # If local branch name or tag is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#where > 32 )) && where[13,-13]="…" + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi - res+="${clean}${where//\%/%%}" # escape % - - # Display the current Git commit if there is no branch or tag. - # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. - [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi # ⇣42 if behind the remote. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 050c7fc..f08078d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -373,29 +373,37 @@ fi local res - local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" - where=${(V)VCS_STATUS_LOCAL_BRANCH} - elif [[ -n $VCS_STATUS_TAG ]]; then - res+="${meta}#" - where=${(V)VCS_STATUS_TAG} + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" fi - # If local branch name or tag is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#where > 32 )) && where[13,-13]="…" + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi - res+="${clean}${where//\%/%%}" # escape % - - # Display the current Git commit if there is no branch or tag. - # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. - [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi # ⇣42 if behind the remote. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 74150d3..f1dca98 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -380,29 +380,37 @@ local conflicted='%1F' # red foreground local res - local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" - where=${(V)VCS_STATUS_LOCAL_BRANCH} - elif [[ -n $VCS_STATUS_TAG ]]; then - res+="${meta}#" - where=${(V)VCS_STATUS_TAG} + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" fi - # If local branch name or tag is at most 32 characters long, show it in full. - # Otherwise show the first 12 … the last 12. - # Tip: To always show local branch name in full without truncation, delete the next line. - (( $#where > 32 )) && where[13,-13]="…" + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi - res+="${clean}${where//\%/%%}" # escape % - - # Display the current Git commit if there is no branch or tag. - # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. - [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then - res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi # ⇣42 if behind the remote.