aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpowerlevel9k.zsh-theme26
1 files changed, 25 insertions, 1 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 26936325..87b453a4 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -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"