zsh:rationalize-dots: Self-insert when replacing

This commit is contained in:
2025-06-02 11:07:04 +02:00
parent d0e5d92d2c
commit 04ef69c021

View File

@@ -152,6 +152,12 @@ bindkey -M vicmd " f" edit-fuzzy-file
# Modified version (end with a trailing slash) of: # Modified version (end with a trailing slash) of:
# https://github.com/majutsushi/etc/blob/1d8a5aa28/zsh/zsh/func/rationalize-dots # https://github.com/majutsushi/etc/blob/1d8a5aa28/zsh/zsh/func/rationalize-dots
function rationalize_dots { function rationalize_dots {
if [[ $ZLE_STATE == *overwrite* ]]; then
# Don't do anything in overwrite-mode (i.e. vim's Replace-mode)
zle self-insert
return
fi
# Rationalize dots at BOL or after a space or slash. # Rationalize dots at BOL or after a space or slash.
if [[ "$LBUFFER" =~ "(^|[ /])\.\./$" ]]; then if [[ "$LBUFFER" =~ "(^|[ /])\.\./$" ]]; then
# ../ + . -> ../../ # ../ + . -> ../../