mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-16 17:50:09 +00:00
Merged truncate_to_unique
& state NOT_WRITABLE
Added `truncate_to_unique` and `NOT_WRITABLE` to @dritter's code.
This commit is contained in:
parent
085a78b9b8
commit
6d25e18779
1 changed files with 25 additions and 1 deletions
|
@ -811,6 +811,27 @@ prompt_dir() {
|
|||
# the current path.
|
||||
current_path=$current_path${PWD#${last_marked_folder}*}
|
||||
;;
|
||||
truncate_to_unique)
|
||||
# for each parent path component find the shortest unique beginning
|
||||
# characters sequence. Source: https://stackoverflow.com/a/45336078
|
||||
paths=(${(s:/:)PWD})
|
||||
cur_path='/'
|
||||
cur_short_path='/'
|
||||
for directory in ${paths[@]}
|
||||
do
|
||||
cur_dir=''
|
||||
for (( i=0; i<${#directory}; i++ )); do
|
||||
cur_dir+="${directory:$i:1}"
|
||||
matching=("$cur_path"/"$cur_dir"*/)
|
||||
if [[ ${#matching[@]} -eq 1 ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
cur_short_path+="$cur_dir/"
|
||||
cur_path+="$directory/"
|
||||
done
|
||||
current_path="${cur_short_path: : -1}"
|
||||
;;
|
||||
*)
|
||||
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
|
||||
;;
|
||||
|
@ -834,9 +855,12 @@ prompt_dir() {
|
|||
"DEFAULT" "FOLDER_ICON"
|
||||
"HOME" "HOME_ICON"
|
||||
"HOME_SUBFOLDER" "HOME_SUB_ICON"
|
||||
"NOT_WRITABLE" "LOCK_ICON"
|
||||
)
|
||||
local current_state="DEFAULT"
|
||||
if [[ $(print -P "%~") == '~' ]]; then
|
||||
if [[ "${POWERLEVEL9K_DIR_SHOW_WRITABLE}" == true && ! -w "$PWD" ]]; then
|
||||
current_state="NOT_WRITABLE"
|
||||
elif [[ $(print -P "%~") == '~' ]]; then
|
||||
current_state="HOME"
|
||||
elif [[ $(print -P "%~") == '~'* ]]; then
|
||||
current_state="HOME_SUBFOLDER"
|
||||
|
|
Loading…
Reference in a new issue