Skip to content

Commit 0b0245e

Browse files
committed
Simplified _agkozak_prompt_dirtrim() logic
1 parent 5e288b5 commit 0b0245e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

agkozak-zsh-theme.plugin.zsh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@ _agkozak_prompt_dirtrim() {
9595
[[ $1 -ge 1 ]] || set 2
9696
local abbreviated_path
9797
case $PWD in
98-
$HOME) print -n '~' ;; # For TrueOS
9998
$HOME*)
100-
abbreviated_path=$(print -Pn "%($(($1 + 2))~|~/.../%${1}~|%~)")
99+
abbreviated_path=$(print -Pn "%($(($1 + ${#HOME//[^\/]/}-1))~|~/.../%$1~|%~)")
101100
;;
102101
*)
103-
abbreviated_path=$(print -Pn "%($(($1 + 1))~|.../%${1}~|%~)")
102+
abbreviated_path=$(print -Pn "%($(($1 + 1))~|.../%$1~|%~)")
104103
;;
105104
esac
106105
print -n "$abbreviated_path"

0 commit comments

Comments
 (0)