aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
Diffstat (limited to 'functions')
-rw-r--r--functions/icons.zsh186
-rw-r--r--functions/utilities.zsh24
-rw-r--r--functions/vcs.zsh45
3 files changed, 163 insertions, 92 deletions
diff --git a/functions/icons.zsh b/functions/icons.zsh
index e7dc3bfa..2f30cff2 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -20,104 +20,112 @@ case $POWERLEVEL9K_MODE in
# Set the right locale to protect special characters
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
icons=(
- LEFT_SEGMENT_SEPARATOR $'\UE0B0' # 
- RIGHT_SEGMENT_SEPARATOR $'\UE0B2' # 
+ LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
+ RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
- LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
- RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
- CARRIAGE_RETURN_ICON $'\U21B5' # ↵
- ROOT_ICON $'\UE801' # 
- RUBY_ICON $'\UE847 ' # 
- AWS_ICON $'\UE895' # 
+ LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' # 
+ RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
+ CARRIAGE_RETURN_ICON $'\u21B5' # ↵
+ ROOT_ICON $'\uE801' # 
+ RUBY_ICON $'\uE847 ' # 
+ AWS_ICON $'\uE895' # 
AWS_EB_ICON $'\U1F331 ' # 🌱
- BACKGROUND_JOBS_ICON $'\UE82F ' # 
- TEST_ICON $'\UE891' # 
- TODO_ICON $'\U2611' # ☑
- BATTERY_ICON $'\UE894' # 
- OK_ICON $'\U2713' # ✓
- FAIL_ICON $'\U2718' # ✘
+ BACKGROUND_JOBS_ICON $'\uE82F ' # 
+ TEST_ICON $'\uE891' # 
+ TODO_ICON $'\u2611' # ☑
+ BATTERY_ICON $'\uE894' # 
+ OK_ICON $'\u2713' # ✓
+ FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
- NODE_ICON $'\U2B22' # ⬢
- MULTILINE_FIRST_PROMPT_PREFIX $'\U256D'$'\U2500'
- MULTILINE_SECOND_PROMPT_PREFIX $'\U2570'$'\U2500 '
- APPLE_ICON $'\UE26E' # 
+ NODE_ICON $'\u2B22' # ⬢
+ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500'
+ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 '
+ APPLE_ICON $'\uE26E' # 
FREEBSD_ICON $'\U1F608 ' # 😈
- LINUX_ICON $'\UE271' # 
+ LINUX_ICON $'\uE271' # 
SUNOS_ICON $'\U1F31E ' # 🌞
- HOME_ICON $'\UE12C' # 
- HOME_SUB_ICON $'\UE18D' # 
- FOLDER_ICON $'\UE818' # 
- NETWORK_ICON $'\UE1AD' # 
- LOAD_ICON $'\UE190 ' # 
- SWAP_ICON $'\UE87D' # 
- RAM_ICON $'\UE1E2 ' # 
- VCS_UNTRACKED_ICON $'\UE16C' # 
- VCS_UNSTAGED_ICON $'\UE17C' # 
- VCS_STAGED_ICON $'\UE168' # 
- VCS_STASH_ICON $'\UE133 ' # 
- #VCS_INCOMING_CHANGES_ICON $'\UE1EB ' # 
- #VCS_INCOMING_CHANGES_ICON $'\UE80D ' # 
- VCS_INCOMING_CHANGES_ICON $'\UE131 ' # 
- #VCS_OUTGOING_CHANGES_ICON $'\UE1EC ' # 
- #VCS_OUTGOING_CHANGES_ICON $'\UE80E ' # 
- VCS_OUTGOING_CHANGES_ICON $'\UE132 ' # 
- VCS_TAG_ICON $'\UE817 ' # 
- VCS_BOOKMARK_ICON $'\UE87B' # 
- VCS_COMMIT_ICON $'\UE821 ' # 
- VCS_BRANCH_ICON $'\UE220' # 
- VCS_REMOTE_BRANCH_ICON ' '$'\UE804 ' # 
- VCS_GIT_ICON $'\UE20E ' # 
- VCS_HG_ICON $'\UE1C3 ' # 
+ HOME_ICON $'\uE12C' # 
+ HOME_SUB_ICON $'\uE18D' # 
+ FOLDER_ICON $'\uE818' # 
+ NETWORK_ICON $'\uE1AD' # 
+ LOAD_ICON $'\uE190 ' # 
+ SWAP_ICON $'\uE87D' # 
+ RAM_ICON $'\uE1E2 ' # 
+ SERVER_ICON $'\uE895' # 
+ VCS_UNTRACKED_ICON $'\uE16C' # 
+ VCS_UNSTAGED_ICON $'\uE17C' # 
+ VCS_STAGED_ICON $'\uE168' # 
+ VCS_STASH_ICON $'\uE133 ' # 
+ #VCS_INCOMING_CHANGES_ICON $'\uE1EB ' # 
+ #VCS_INCOMING_CHANGES_ICON $'\uE80D ' # 
+ VCS_INCOMING_CHANGES_ICON $'\uE131 ' # 
+ #VCS_OUTGOING_CHANGES_ICON $'\uE1EC ' # 
+ #VCS_OUTGOING_CHANGES_ICON $'\uE80E ' # 
+ VCS_OUTGOING_CHANGES_ICON $'\uE132 ' # 
+ VCS_TAG_ICON $'\uE817 ' # 
+ VCS_BOOKMARK_ICON $'\uE87B' # 
+ VCS_COMMIT_ICON $'\uE821 ' # 
+ VCS_BRANCH_ICON $'\uE220' # 
+ VCS_REMOTE_BRANCH_ICON ' '$'\uE804 ' # 
+ VCS_GIT_ICON $'\uE20E ' # 
+ VCS_HG_ICON $'\uE1C3 ' # 
+ VCS_SVN_ICON '(svn) '
+ RUST_ICON ''
+ PYTHON_ICON $'\U1F40D' # 🐍
)
;;
'awesome-fontconfig')
# fontconfig with awesome-font required! See
# https://github.com/gabrielelana/awesome-terminal-fonts
icons=(
- LEFT_SEGMENT_SEPARATOR $'\UE0B0' # 
- RIGHT_SEGMENT_SEPARATOR $'\UE0B2' # 
+ LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
+ RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
- LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
- RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
- CARRIAGE_RETURN_ICON $'\U21B5' # ↵
+ LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' # 
+ RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
+ CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\uF201' # 
- RUBY_ICON $'\UF219 ' # 
- AWS_ICON $'\UF296' # 
+ RUBY_ICON $'\uF219 ' # 
+ AWS_ICON $'\uF296' # 
AWS_EB_ICON $'\U1F331 ' # 🌱
- BACKGROUND_JOBS_ICON $'\UF013 ' # 
- TEST_ICON $'\UF291' # 
- TODO_ICON $'\U2611' # ☑
- BATTERY_ICON $'\u1F50B' # 🔋
- OK_ICON $'\UF23A' # 
- FAIL_ICON $'\UF281' # 
+ BACKGROUND_JOBS_ICON $'\uF013 ' # 
+ TEST_ICON $'\uF291' # 
+ TODO_ICON $'\u2611' # ☑
+ BATTERY_ICON $'\U1F50B' # 🔋
+ OK_ICON $'\uF23A' # 
+ FAIL_ICON $'\uF281' # 
SYMFONY_ICON 'SF'
- NODE_ICON $'\U2B22' # ⬢
- MULTILINE_FIRST_PROMPT_PREFIX $'\U256D'$'\U2500' # ╭─
- MULTILINE_SECOND_PROMPT_PREFIX $'\U2570'$'\U2500 ' # ╰─
- APPLE_ICON $'\UF179' # 
+ NODE_ICON $'\u2B22' # ⬢
+ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
+ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
+ APPLE_ICON $'\uF179' # 
FREEBSD_ICON $'\U1F608 ' # 😈
- LINUX_ICON $'\UF17C' # 
- SUNOS_ICON $'\UF185 ' # 
- HOME_ICON $'\UF015' # 
- HOME_SUB_ICON $'\UF07C' # 
- FOLDER_ICON $'\UF115' # 
- NETWORK_ICON $'\UF09E' # 
- LOAD_ICON $'\UF080 ' # 
- SWAP_ICON $'\UF0E4' # 
- RAM_ICON $'\UF0E4' # 
- VCS_UNTRACKED_ICON $'\UF059' # 
- VCS_UNSTAGED_ICON $'\UF06A' # 
- VCS_STAGED_ICON $'\UF055' # 
- VCS_STASH_ICON $'\UF01C ' # 
- VCS_INCOMING_CHANGES_ICON $'\UF01A ' # 
- VCS_OUTGOING_CHANGES_ICON $'\UF01B ' # 
- VCS_TAG_ICON $'\UF217 ' # 
- VCS_BOOKMARK_ICON $'\UF27B' # 
- VCS_COMMIT_ICON $'\UF221 ' # 
- VCS_BRANCH_ICON $'\UF126' # 
- VCS_REMOTE_BRANCH_ICON ' '$'\UF204 ' # 
- VCS_GIT_ICON $'\UF113 ' # 
- VCS_HG_ICON $'\UF0C3 ' # 
+ LINUX_ICON $'\uF17C' # 
+ SUNOS_ICON $'\uF185 ' # 
+ HOME_ICON $'\uF015' # 
+ HOME_SUB_ICON $'\uF07C' # 
+ FOLDER_ICON $'\uF115' # 
+ NETWORK_ICON $'\uF09E' # 
+ LOAD_ICON $'\uF080 ' # 
+ SWAP_ICON $'\uF0E4' # 
+ RAM_ICON $'\uF0E4' # 
+ SERVER_ICON $'\uF296' # 
+ VCS_UNTRACKED_ICON $'\uF059' # 
+ VCS_UNSTAGED_ICON $'\uF06A' # 
+ VCS_STAGED_ICON $'\uF055' # 
+ VCS_STASH_ICON $'\uF01C ' # 
+ VCS_INCOMING_CHANGES_ICON $'\uF01A ' # 
+ VCS_OUTGOING_CHANGES_ICON $'\uF01B ' # 
+ VCS_TAG_ICON $'\uF217 ' # 
+ VCS_BOOKMARK_ICON $'\uF27B' # 
+ VCS_COMMIT_ICON $'\uF221 ' # 
+ VCS_BRANCH_ICON $'\uF126' # 
+ VCS_REMOTE_BRANCH_ICON ' '$'\uF204 ' # 
+ VCS_GIT_ICON $'\uF113 ' # 
+ VCS_HG_ICON $'\uF0C3 ' # 
+ VCS_SVN_ICON '(svn) '
+ RUST_ICON $'\uE6A8' # 
+ PYTHON_ICON $'\U1F40D' # 🐍
)
;;
*)
@@ -127,17 +135,17 @@ case $POWERLEVEL9K_MODE in
LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
- LEFT_SUBSEGMENT_SEPARATOR $'\UE0B1' # 
- RIGHT_SUBSEGMENT_SEPARATOR $'\UE0B3' # 
- CARRIAGE_RETURN_ICON $'\U21B5' # ↵
+ LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' # 
+ RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
+ CARRIAGE_RETURN_ICON $'\u21B5' # ↵
ROOT_ICON $'\u26A1' # ⚡
RUBY_ICON ''
AWS_ICON 'AWS:'
AWS_EB_ICON $'\U1F331 ' # 🌱
BACKGROUND_JOBS_ICON $'\u2699' # ⚙
TEST_ICON ''
- TODO_ICON $'\U2611' # ☑
- BATTERY_ICON $'\u1F50B' # 🔋
+ TODO_ICON $'\u2611' # ☑
+ BATTERY_ICON $'\U1F50B' # 🔋
OK_ICON $'\u2713' # ✓
FAIL_ICON $'\u2718' # ✘
SYMFONY_ICON 'SF'
@@ -155,6 +163,7 @@ case $POWERLEVEL9K_MODE in
LOAD_ICON 'L'
SWAP_ICON 'SWP'
RAM_ICON 'RAM'
+ SERVER_ICON ''
VCS_UNTRACKED_ICON '?'
VCS_UNSTAGED_ICON $'\u25CF' # ●
VCS_STAGED_ICON $'\u271A' # ✚
@@ -168,6 +177,9 @@ case $POWERLEVEL9K_MODE in
VCS_REMOTE_BRANCH_ICON $'\u2192' # →
VCS_GIT_ICON ''
VCS_HG_ICON ''
+ VCS_SVN_ICON ''
+ RUST_ICON ''
+ PYTHON_ICON ''
)
;;
esac
diff --git a/functions/utilities.zsh b/functions/utilities.zsh
index 5ca5b431..f27c7f99 100644
--- a/functions/utilities.zsh
+++ b/functions/utilities.zsh
@@ -122,6 +122,20 @@ if [[ "$OS" == 'OSX' ]]; then
fi
fi
+# Determine if the passed segment is used in the prompt
+#
+# Pass the name of the segment to this function to test for its presence in
+# either the LEFT or RIGHT prompt arrays.
+# * $1: The segment to be tested.
+segment_in_use() {
+ local key=$1
+ if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
# Print a deprecation warning if an old segment is in use.
# Takes the name of an associative array that contains the
# deprecated segments as keys, the values contain the new
@@ -131,7 +145,7 @@ print_deprecation_warning() {
raw_deprecated_segments=(${(kvP@)1})
for key in ${(@k)raw_deprecated_segments}; do
- if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then
+ if segment_in_use $key; then
# segment is deprecated
print -P "%F{yellow}Warning!%f The '$key' segment is deprecated. Use '%F{blue}${raw_deprecated_segments[$key]}%f' instead. For more informations, have a look at the CHANGELOG.md."
fi
@@ -186,3 +200,11 @@ function segmentShouldBeJoined() {
return 1
fi
}
+
+# Given a directory path, truncate it according to the settings for
+# `truncate_from_right`
+function truncatePathFromRight() {
+ local delim_len=${#POWERLEVEL9K_SHORTEN_DELIMITER}
+ echo $1 | sed $SED_EXTENDED_REGEX_PARAMETER \
+ "s@(([^/]{$((POWERLEVEL9K_SHORTEN_DIR_LENGTH))})([^/]{$delim_len}))[^/]+/@\2$POWERLEVEL9K_SHORTEN_DELIMITER/@g"
+}
diff --git a/functions/vcs.zsh b/functions/vcs.zsh
index 9d3883ca..93925f15 100644
--- a/functions/vcs.zsh
+++ b/functions/vcs.zsh
@@ -60,11 +60,30 @@ function +vi-git-remotebranch() {
fi
}
+set_default POWERLEVEL9K_VCS_HIDE_TAGS false
function +vi-git-tagname() {
- local tag
-
- tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
- [[ -n "${tag}" ]] && hook_com[branch]="$(print_icon 'VCS_TAG_ICON')${tag}"
+ if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then
+ # If we are on a tag, append the tagname to the current branch string.
+ local tag
+ tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
+
+ if [[ -n "${tag}" ]] ; then
+ # There is a tag that points to our current commit. Need to determine if we
+ # are also on a branch, or are in a DETACHED_HEAD state.
+ if [[ -z $(git symbolic-ref HEAD 2>/dev/null) ]]; then
+ # DETACHED_HEAD state. We want to append the tag name to the commit hash
+ # and print it. Unfortunately, `vcs_info` blows away the hash when a tag
+ # exists, so we have to manually retrieve it and clobber the branch
+ # string.
+ local revision
+ revision=$(git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD)
+ hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}"
+ else
+ # We are on both a tag and a branch; print both by appending the tag name.
+ hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
+ fi
+ fi
+ fi
}
# Show count of stashed changes
@@ -94,6 +113,8 @@ function +vi-vcs-detect-changes() {
vcs_visual_identifier='VCS_GIT_ICON'
elif [[ "${hook_com[vcs]}" == "hg" ]]; then
vcs_visual_identifier='VCS_HG_ICON'
+ elif [[ "${hook_com[vcs]}" == "svn" ]]; then
+ vcs_visual_identifier='VCS_SVN_ICON'
fi
if [[ -n "${hook_com[staged]}" ]] || [[ -n "${hook_com[unstaged]}" ]]; then
@@ -102,3 +123,19 @@ function +vi-vcs-detect-changes() {
VCS_WORKDIR_DIRTY=false
fi
}
+
+function +vi-svn-detect-changes() {
+ local svn_status="$(svn status)"
+ if [[ -n "$(echo "$svn_status" | grep \^\?)" ]]; then
+ hook_com[unstaged]+=" $(print_icon 'VCS_UNTRACKED_ICON')"
+ VCS_WORKDIR_HALF_DIRTY=true
+ fi
+ if [[ -n "$(echo "$svn_status" | grep \^\M)" ]]; then
+ hook_com[unstaged]+=" $(print_icon 'VCS_UNSTAGED_ICON')"
+ VCS_WORKDIR_DIRTY=true
+ fi
+ if [[ -n "$(echo "$svn_status" | grep \^\A)" ]]; then
+ hook_com[staged]+=" $(print_icon 'VCS_STAGED_ICON')"
+ VCS_WORKDIR_DIRTY=true
+ fi
+}