aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorBenoit Averty <benoit.averty@gmail.com>2016-08-10 22:31:58 +0300
committerDominik Ritter <dritter03@googlemail.com>2017-02-01 01:49:46 +0300
commit9f4772f9930c7d56ab04df900ac94456e5a08a22 (patch)
treee1610866495a79d1ec3df311a1cbe3f9b5fe4a24 /powerlevel9k.zsh-theme
parent5cc2d51b5829d0ae2eefaa115892da71f6a14d79 (diff)
More possibilities with truncate folder marker
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme30
1 files changed, 18 insertions, 12 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index afc4a6bc..420f7d0b 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -571,7 +571,7 @@ prompt_custom() {
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
prompt_dir() {
local current_path='%~'
- if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_root_marker" ]]; then
+ if [[ -n "$POWERLEVEL9K_SHORTEN_DIR_LENGTH" || "$POWERLEVEL9K_SHORTEN_STRATEGY" == "truncate_with_folder_marker" ]]; then
set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026'
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
@@ -609,19 +609,25 @@ prompt_dir() {
current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" )
fi
;;
- truncate_with_root_marker)
- local dir_truncate_root
+ truncate_with_folder_marker)
+ local last_marked_folder marked_folder zero
+ set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker"
+
+ for marked_folder in $(upsearch $POWERLEVEL9K_SHORTEN_FOLDER_MARKER); do
+ if [[ "$marked_folder" == "/" ]]; then
+ current_path="/"
+ elif [[ "$marked_folder" == "$HOME" ]]; then
+ 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
- dir_truncate_root=$(upsearch $POWERLEVEL9K_ROOT_MARKER_FILE)
zero='%([BSUbfksu]|([FB]|){*})'
-
- if [[ "$dir_truncate_root" == "/" || "$dir_truncate_root" == "$HOME" || "${dir_truncate_root%/*}" == "$HOME" || ${dir_truncate_root%/*} == "/" ]]; then
- current_path='%~'
- elif [[ "$dir_truncate_root" == "$HOME"* ]]; then
- current_path="~/$POWERLEVEL9K_SHORTEN_DELIMITER/${dir_truncate_root##*/}${PWD:${#${(S%%)dir_truncate_root//$~zero/}}}"
- else
- current_path="/$POWERLEVEL9K_SHORTEN_DELIMITER/${dir_truncate_root##*/}${PWD:${#${(S%%)dir_truncate_root//$~zero/}}}"
- fi
+ current_path=$current_path${PWD:${#${(S%%)last_marked_folder//$~zero/}}}
;;
*)
current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"