From 1ffd31d5850cc99fa1bf800b715220a81387726f Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 30 Oct 2024 16:13:16 +0100 Subject: [PATCH] zsh:keys: Use (A) flag instead of hack to split LBUFFER This way better solution using the `(A)` flag was given to me in the zsh-users mailing list back in 2022 but I forgot to apply it. See zshexpn(1): > Convert the substitution into an array expression, even if it > otherwise would be scalar. Thanks Mikael! Link: https://www.zsh.org/mla/users/2022/msg00668.html --- .config/zsh/zshrc.d/60-keys.zsh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.config/zsh/zshrc.d/60-keys.zsh b/.config/zsh/zshrc.d/60-keys.zsh index b5c9a6f..f5db8d7 100644 --- a/.config/zsh/zshrc.d/60-keys.zsh +++ b/.config/zsh/zshrc.d/60-keys.zsh @@ -159,13 +159,9 @@ 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_words}[-1]:a}" + zle -M "${(D)${(Az)LBUFFER}[-1]:a}" } zle -N rationalize_dots bindkey . rationalize_dots