1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-22 15:21:56 +00:00

append POWERLEVEL9K_SHORTEN_DELIMITER when shortening with truncate_to_unique; use * as default in this case

This commit is contained in:
romkatv 2019-05-19 12:46:28 +02:00
parent 15e7d74087
commit 3c5b52750e
2 changed files with 7 additions and 4 deletions

View file

@ -32,8 +32,10 @@ function set_default() {
}
function _p9k_g_expand() {
(( $+parameters[$1] )) || return
local -a ts=("${=$(typeset -p $1)}")
shift ts
local x
for x in "${ts[@]}"; do
[[ $x == -* ]] || break
# Don't change readonly variables. Ideally, we shouldn't modify any variables at all,

View file

@ -792,7 +792,6 @@ set_default POWERLEVEL9K_DIR_SHOW_WRITABLE false
set_default POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER false
set_default POWERLEVEL9K_SHORTEN_STRATEGY ""
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND ""
set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\u2026'
# This defines a pattern. It is expanded with the options set by `emulate zsh`.
# This works pretty well: POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(.bzr|CVS|.git|.hg|.svn|.citc)"
set_default POWERLEVEL9K_SHORTEN_FOLDER_MARKER ".shorten_folder_marker"
@ -830,6 +829,7 @@ prompt_dir() {
fi
local -i fake_first=0
local delim=${POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'}
case $POWERLEVEL9K_SHORTEN_STRATEGY in
truncate_absolute|truncate_absolute_chars)
@ -900,13 +900,14 @@ prompt_dir() {
for (( ; i < $#parts; ++i )); do
local dir=$parts[i]
local -i j=1
for (( ; j <= $#dir; ++j )); do
for (( ; j < $#dir; ++j )); do
local -a matching=($parent/$dir[1,j]*/(N))
(( $#matching == 1 )) && break
done
parent+=/$dir
parts[i]=$dir[1,j]
(( j == $#dir )) || parts[i]=$dir[1,j]$'\0'
done
delim=${POWERLEVEL9K_SHORTEN_DELIMITER-'*'}
;;
truncate_with_folder_marker)
local dir=$PWD
@ -962,7 +963,7 @@ prompt_dir() {
last_fg+=$_P9K_RETVAL
fi
parts[-1]=$last_fg${parts[-1]//$'\0'/$'\0'$last_fg}
parts=("${(@)parts//$'\0'/$POWERLEVEL9K_SHORTEN_DELIMITER$fg}")
parts=("${(@)parts//$'\0'/$delim$fg}")
local sep=$POWERLEVEL9K_DIR_PATH_SEPARATOR$fg
if [[ -n $POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND ]]; then