aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme60
1 files changed, 30 insertions, 30 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 53f115c3..70aca115 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -756,7 +756,7 @@ prompt_dir() {
test_dir="$paths[$i]"
test_dir_length=${#test_dir}
threshhold=$(( $POWERLEVEL9K_SHORTEN_DIR_LENGTH + ${#delim} ))
- if (( $test_dir_length > $threshhold )); then # only shorten if long enough
+ if (( $test_dir_length > $threshhold && $test_dir_length > 3 )); then # only shorten if long enough
trunc_path+="${test_dir:0:$POWERLEVEL9K_SHORTEN_DIR_LENGTH}$delim/"
else
trunc_path+="${test_dir}/"
@@ -765,6 +765,32 @@ prompt_dir() {
current_path=$trunc_path${current_path:t}
fi
;;
+ truncate_with_folder_marker)
+ local last_marked_folder marked_folder
+ set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker"
+
+ # Search for the folder marker in the parent directories and
+ # buildup a pattern that is removed from the current path
+ # later on.
+ for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do
+ if [[ "$marked_folder" == "/" ]]; then
+ # If we reached root folder, stop upsearch.
+ current_path="/"
+ elif [[ "$marked_folder" == "$HOME" ]]; then
+ # If we reached home folder, stop upsearch.
+ current_path="~"
+ elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then
+ current_path="${current_path%/}/${marked_folder##*/}"
+ else
+ current_path="${current_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}"
+ fi
+ last_marked_folder=$marked_folder
+ done
+
+ # Replace the shortest possible match of the marked folder from
+ # the current path.
+ current_path=$current_path${current_path#${last_marked_folder}*}
+ ;;
truncate_with_package_name)
local name repo_path package_path current_dir zero
@@ -775,11 +801,11 @@ prompt_dir() {
# Remove trailing slash from git path, so that we can
# remove that git path from the pwd.
gitPath=${gitPath%/}
- package_path=${current_dir%%$gitPath}
+ package_path=${current_path%%$gitPath}
# Remove trailing slash
package_path=${package_dir%/}
elif [[ $(git rev-parse --is-inside-git-dir 2> /dev/null) == "true" ]]; then
- package_path=${current_dir%%/.git*}
+ package_path=${current_path%%/.git*}
fi
# Replace the shortest possible match of the marked folder from
@@ -791,7 +817,7 @@ prompt_dir() {
# Then, find the length of the package_path string, and save the
# subdirectory path as a substring of the current directory's path from 0
# to the length of the package path's string
- subdirectory_path=$(truncatePathFromRight "${current_dir:${#${(S%%)package_path//$~zero/}}}")
+ subdirectory_path=$(truncatePathFromRight "${current_path:${#${(S%%)package_path//$~zero/}}}")
# Parse the 'name' from the package.json; if there are any problems, just
# print the file path
defined POWERLEVEL9K_DIR_PACKAGE_FILES || POWERLEVEL9K_DIR_PACKAGE_FILES=(package.json composer.json)
@@ -816,32 +842,6 @@ prompt_dir() {
current_path=$(truncatePathFromRight ${current_path//$HOME/"~"} )
fi
;;
- truncate_with_folder_marker)
- local last_marked_folder marked_folder
- set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker"
-
- # Search for the folder marker in the parent directories and
- # buildup a pattern that is removed from the current path
- # later on.
- for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do
- if [[ "$marked_folder" == "/" ]]; then
- # If we reached root folder, stop upsearch.
- current_path="/"
- elif [[ "$marked_folder" == "$HOME" ]]; then
- # If we reached home folder, stop upsearch.
- current_path="~"
- elif [[ "${marked_folder%/*}" == $last_marked_folder ]]; then
- current_path="${current_path%/}/${marked_folder##*/}"
- else
- current_path="${current_path%/}/$POWERLEVEL9K_SHORTEN_DELIMITER/${marked_folder##*/}"
- fi
- last_marked_folder=$marked_folder
- done
-
- # Replace the shortest possible match of the marked folder from
- # the current path.
- current_path=$current_path${current_dir#${last_marked_folder}*}
- ;;
truncate_to_unique)
# for each parent path component find the shortest unique beginning
# characters sequence. Source: https://stackoverflow.com/a/45336078