aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-24 20:53:02 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-24 20:53:02 +0300
commitf1314f9072f6fdb20d31c2ad5a0d0c431d803fd4 (patch)
tree14b28c424816210ac1e2c87548410d4acb47cf87 /internal/p10k.zsh
parentcf886d0baf47c9f1cf58ed2278cb7b4bea0d808b (diff)
parent833cc73f73dc46744b21683f92d4ac55eb9c369b (diff)
Merge branch 'master' into worker
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh42
1 files changed, 36 insertions, 6 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 6bc71022..b91f4fca 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1560,7 +1560,12 @@ prompt_dir() {
shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1}
(( shortenlen >= 0 )) || shortenlen=1
local -i i=2 e=$(($#parts - shortenlen))
- [[ $p[1] == / ]] && (( ++i ))
+ if (( _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER )); then
+ (( e += shortenlen ))
+ local orig=("$parts[2]" "${(@)parts[$((shortenlen > $#parts ? -$#parts : -shortenlen)),-1]}")
+ elif [[ $p[1] == / ]]; then
+ (( ++i ))
+ fi
local parent="${_p9k__pwd%/${(pj./.)parts[i,-1]}}"
if (( i <= e )); then
local MATCH= mtimes=()
@@ -1611,11 +1616,34 @@ prompt_dir() {
fi
parent+=/$sub
done
- for ((; i <= $#parts; ++i)); do
- [[ $parts[i] == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] && parts[i]='${(Q)${:-'${(qqq)${(q)parts[i]}}'}}'
- parts[i]+=$'\2'
- done
- [[ -n $key ]] && _p9k_cache_ephemeral_set "$key" "${parts[@]}"
+ if (( _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER )); then
+ local _2=$'\2'
+ (( e = ${parts[(I)*$_2]} ))
+ if (( e > 1 )); then
+ parts[1,e-1]=()
+ fake_first=1
+ elif [[ $p == /?* ]]; then
+ parts[2]="\${(Q)\${:-${(qqq)${(q)orig[1]}}}}"$'\2'
+ fi
+ for ((i = $#parts < shortenlen ? $#parts : shortenlen; i > 0; --i)); do
+ [[ $#parts[-i] == *$'\2' ]] && continue
+ if [[ $orig[-i] == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]]; then
+ parts[-i]='${(Q)${:-'${(qqq)${(q)orig[-i]}}'}}'$'\2'
+ else
+ parts[-i]=${orig[-i]}$'\2'
+ fi
+ done
+ else
+ for ((; i <= $#parts; ++i)); do
+ [[ $parts[i] == *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] && parts[i]='${(Q)${:-'${(qqq)${(q)parts[i]}}'}}'
+ parts[i]+=$'\2'
+ done
+ fi
+ if [[ -n $key ]]; then
+ _p9k_cache_ephemeral_set "$key" "${parts[@]}"
+ else
+ _p9k_cache_val=("$key" "${parts[@]}")
+ fi
fi
parts=("${(@)_p9k_cache_val[2,-1]}")
;;
@@ -5204,6 +5232,8 @@ _p9k_init_params() {
_p9k_declare -a POWERLEVEL9K_DIR_CLASSES
_p9k_declare -i POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH
_p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER
+ _p9k_declare -b POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER
+ [[ -z $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]] && _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=0
_p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH
_p9k_declare -s POWERLEVEL9K_IP_INTERFACE ""
: ${_POWERLEVEL9K_IP_INTERFACE:='.*'}