File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -164,17 +164,23 @@ _agkozak_prompt_dirtrim() {
164164 * ) print -Pn " %($(( $1 + 1 )) /|.../%${1} d|%d)" ;;
165165 esac
166166 else
167+ local dir dir_count
168+ case $HOME in
169+ /) dir=${PWD} ;;
170+ * ) dir=${PWD# $HOME } ;;
171+ esac
167172 # The number of directory elements is the number of slashes in ${PWD#$HOME}
168- local dir_count=$(( ${# ${PWD # $HOME } } - ${# ${${PWD # HOME} // \/ / } } ))
173+ dir_count=$(( ${# dir} - ${# ${dir // \/ / } } ))
169174
170175 if (( dir_count <= $1 )) ; then
171176 case $PWD in
172- ${HOME} * ) printf ' ~%s' " ${PWD# $HOME } " ;;
177+ ${HOME} ) printf ' %s' ' ~' ;;
178+ ${HOME} * ) printf ' ~%s' " ${dir} " ;;
173179 * ) print -n " $PWD " ;;
174180 esac
175181 else
176182 local lopped_path i
177- lopped_path=${PWD # $HOME }
183+ lopped_path=${dir }
178184 i=0
179185 while (( i != $1 )) ; do
180186 lopped_path=${lopped_path% \/ * }
You can’t perform that action at this time.
0 commit comments