mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-12 08:10:07 +00:00
More possibilities with truncate folder marker
This commit is contained in:
parent
5cc2d51b58
commit
9f4772f993
2 changed files with 27 additions and 20 deletions
|
@ -211,15 +211,16 @@ function truncatePathFromRight() {
|
||||||
|
|
||||||
# Search recursively in parent folders for given file.
|
# Search recursively in parent folders for given file.
|
||||||
function upsearch () {
|
function upsearch () {
|
||||||
if test -e "$1"; then
|
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
|
||||||
|
echo "$PWD"
|
||||||
|
elif test -e "$1"; then
|
||||||
|
pushd .. > /dev/null
|
||||||
|
upsearch "$1"
|
||||||
|
popd > /dev/null
|
||||||
echo "$PWD"
|
echo "$PWD"
|
||||||
else
|
else
|
||||||
if [[ "$PWD" == "/" || "$PWD" == "$HOME" ]]; then
|
pushd .. > /dev/null
|
||||||
echo "$PWD";
|
upsearch "$1"
|
||||||
else
|
popd > /dev/null
|
||||||
pushd .. > /dev/null
|
|
||||||
upsearch "$1"
|
|
||||||
popd > /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -571,7 +571,7 @@ prompt_custom() {
|
||||||
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
|
set_default POWERLEVEL9K_DIR_PATH_SEPARATOR "/"
|
||||||
prompt_dir() {
|
prompt_dir() {
|
||||||
local current_path='%~'
|
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'
|
set_default POWERLEVEL9K_SHORTEN_DELIMITER $'\U2026'
|
||||||
|
|
||||||
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
|
case "$POWERLEVEL9K_SHORTEN_STRATEGY" in
|
||||||
|
@ -609,19 +609,25 @@ prompt_dir() {
|
||||||
current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" )
|
current_path=$(truncatePathFromRight "$(pwd | sed -e "s,^$HOME,~,")" )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
truncate_with_root_marker)
|
truncate_with_folder_marker)
|
||||||
local dir_truncate_root
|
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]|){*})'
|
zero='%([BSUbfksu]|([FB]|){*})'
|
||||||
|
current_path=$current_path${PWD:${#${(S%%)last_marked_folder//$~zero/}}}
|
||||||
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="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
|
current_path="%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c"
|
||||||
|
|
Loading…
Reference in a new issue