mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-21 20:00:07 +00:00
support POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=first; see #669
This commit is contained in:
parent
eb66d0e66a
commit
7c4b0f36c0
5 changed files with 38 additions and 24 deletions
|
@ -242,10 +242,11 @@
|
||||||
stack.yaml
|
stack.yaml
|
||||||
)
|
)
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
||||||
# If set to true, remove everything before the last (deepest) subdirectory that contains files
|
# If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
|
||||||
# matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
# files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
||||||
# /foo/bar/git_repo/baz, prompt will display git_repo/baz. This assumes that /foo/bar/git_repo
|
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
|
||||||
# contains a marker (.git) and other directories don't.
|
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
|
||||||
|
# and other directories don't.
|
||||||
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
||||||
# Don't shorten this many last directory segments. They are anchors.
|
# Don't shorten this many last directory segments. They are anchors.
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||||
|
|
|
@ -236,10 +236,11 @@
|
||||||
stack.yaml
|
stack.yaml
|
||||||
)
|
)
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
||||||
# If set to true, remove everything before the last (deepest) subdirectory that contains files
|
# If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
|
||||||
# matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
# files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
||||||
# /foo/bar/git_repo/baz, prompt will display git_repo/baz. This assumes that /foo/bar/git_repo
|
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
|
||||||
# contains a marker (.git) and other directories don't.
|
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
|
||||||
|
# and other directories don't.
|
||||||
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
||||||
# Don't shorten this many last directory segments. They are anchors.
|
# Don't shorten this many last directory segments. They are anchors.
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||||
|
|
|
@ -236,10 +236,11 @@
|
||||||
stack.yaml
|
stack.yaml
|
||||||
)
|
)
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
||||||
# If set to true, remove everything before the last (deepest) subdirectory that contains files
|
# If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
|
||||||
# matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
# files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
||||||
# /foo/bar/git_repo/baz, prompt will display git_repo/baz. This assumes that /foo/bar/git_repo
|
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
|
||||||
# contains a marker (.git) and other directories don't.
|
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
|
||||||
|
# and other directories don't.
|
||||||
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
||||||
# Don't shorten this many last directory segments. They are anchors.
|
# Don't shorten this many last directory segments. They are anchors.
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||||
|
|
|
@ -242,10 +242,11 @@
|
||||||
stack.yaml
|
stack.yaml
|
||||||
)
|
)
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
||||||
# If set to true, remove everything before the last (deepest) subdirectory that contains files
|
# If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
|
||||||
# matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
# files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
|
||||||
# /foo/bar/git_repo/baz, prompt will display git_repo/baz. This assumes that /foo/bar/git_repo
|
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
|
||||||
# contains a marker (.git) and other directories don't.
|
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
|
||||||
|
# and other directories don't.
|
||||||
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
|
||||||
# Don't shorten this many last directory segments. They are anchors.
|
# Don't shorten this many last directory segments. They are anchors.
|
||||||
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||||
|
|
|
@ -1765,7 +1765,7 @@ prompt_dir() {
|
||||||
shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1}
|
shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1}
|
||||||
(( shortenlen >= 0 )) || shortenlen=1
|
(( shortenlen >= 0 )) || shortenlen=1
|
||||||
local -i i=2 e=$(($#parts - shortenlen))
|
local -i i=2 e=$(($#parts - shortenlen))
|
||||||
if (( _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER )); then
|
if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then
|
||||||
(( e += shortenlen ))
|
(( e += shortenlen ))
|
||||||
local orig=("$parts[2]" "${(@)parts[$((shortenlen > $#parts ? -$#parts : -shortenlen)),-1]}")
|
local orig=("$parts[2]" "${(@)parts[$((shortenlen > $#parts ? -$#parts : -shortenlen)),-1]}")
|
||||||
elif [[ $p[1] == / ]]; then
|
elif [[ $p[1] == / ]]; then
|
||||||
|
@ -1777,7 +1777,7 @@ prompt_dir() {
|
||||||
else
|
else
|
||||||
local key=
|
local key=
|
||||||
fi
|
fi
|
||||||
if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd || [[ $key != $_p9k__cache_val[1] ]] ; then
|
if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd || [[ $key != $_p9k__cache_val[1] ]]; then
|
||||||
local tail=${(j./.)parts[i,-1]}
|
local tail=${(j./.)parts[i,-1]}
|
||||||
local parent=$_p9k__cwd[1,-2-$#tail]
|
local parent=$_p9k__cwd[1,-2-$#tail]
|
||||||
_p9k_prompt_length $delim
|
_p9k_prompt_length $delim
|
||||||
|
@ -1821,10 +1821,14 @@ prompt_dir() {
|
||||||
fi
|
fi
|
||||||
parent+=/$sub
|
parent+=/$sub
|
||||||
done
|
done
|
||||||
if (( _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER )); then
|
if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then
|
||||||
local _2=$'\2'
|
local _2=$'\2'
|
||||||
(( e = ${parts[(I)*$_2]} ))
|
if [[ $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER == last ]]; then
|
||||||
if (( e > 1 )); then
|
(( e = ${parts[(I)*$_2]} ))
|
||||||
|
else
|
||||||
|
(( e = ${parts[(ib:2:)*$_2]} ))
|
||||||
|
fi
|
||||||
|
if (( e > 1 && e <= $#parts )); then
|
||||||
parts[1,e-1]=()
|
parts[1,e-1]=()
|
||||||
fake_first=1
|
fake_first=1
|
||||||
elif [[ $p == /?* ]]; then
|
elif [[ $p == /?* ]]; then
|
||||||
|
@ -6852,8 +6856,14 @@ _p9k_init_params() {
|
||||||
_p9k_declare -a POWERLEVEL9K_DIR_CLASSES
|
_p9k_declare -a POWERLEVEL9K_DIR_CLASSES
|
||||||
_p9k_declare -i POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH
|
_p9k_declare -i POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH
|
||||||
_p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER
|
_p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER
|
||||||
_p9k_declare -b POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER
|
_p9k_declare -s POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ''
|
||||||
[[ -z $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]] && _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=0
|
case $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER in
|
||||||
|
first) ;;
|
||||||
|
last) ;;
|
||||||
|
true) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=last;;
|
||||||
|
*) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=;;
|
||||||
|
esac
|
||||||
|
[[ -z $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]] && _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=
|
||||||
_p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH
|
_p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH
|
||||||
_p9k_declare -s POWERLEVEL9K_IP_INTERFACE ""
|
_p9k_declare -s POWERLEVEL9K_IP_INTERFACE ""
|
||||||
: ${_POWERLEVEL9K_IP_INTERFACE:='.*'}
|
: ${_POWERLEVEL9K_IP_INTERFACE:='.*'}
|
||||||
|
@ -7568,7 +7578,7 @@ _p9k_must_init() {
|
||||||
[[ $sig == $_p9k__param_sig ]] && return 1
|
[[ $sig == $_p9k__param_sig ]] && return 1
|
||||||
_p9k_deinit
|
_p9k_deinit
|
||||||
fi
|
fi
|
||||||
_p9k__param_pat=$'v78\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
_p9k__param_pat=$'v79\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
|
||||||
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
|
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
|
||||||
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
|
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
|
||||||
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays\1'
|
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays\1'
|
||||||
|
|
Loading…
Reference in a new issue