diff --git a/.config/zsh/zshrc.d/60-keys.zsh b/.config/zsh/zshrc.d/60-keys.zsh index 55b44a3..fd82190 100644 --- a/.config/zsh/zshrc.d/60-keys.zsh +++ b/.config/zsh/zshrc.d/60-keys.zsh @@ -100,9 +100,13 @@ function rationalize_dots { return fi + # NOTE: This is a hack to fix the (z) expansion flag if the path is the only + # word in LBUFFER, as then [:-1] treats the expansion as a scalar and + # returns the last character (i.e. always `/`). + local lbuffer_words="x $LBUFFER" # Print currently typed path as absolute path with "collapsed"/reversed # filename expansion. - zle -M "${(D)${(z)LBUFFER}[-1]:a}" + zle -M "${(D)${(z)lbuffer_words}[-1]:a}" } zle -N rationalize_dots bindkey . rationalize_dots