No zsh, posso fazer isso com os atalhos do Emacs. Seu exemplo acima seria Alt-Backspace (ou M-DEL
no jargão do Emacs).
Para fazer isso, tenho o seguinte em .zshrc
. (Observe a URL - não estou aceitando isso!)
## emacs cursor-word movement (not identical but close enough)
# also necessary for this:
# /usr/share/zsh/functions/forward-word-match
# (from http://stackoverflow.com/questions/10847255 )
autoload -U select-word-style
select-word-style bash
O arquivo mencionado é assim:
emulate -L zsh
setopt extendedglob
local curcontext=":zle:$WIDGET" word
local -a matched_words
integer count=${NUMERIC:-1}
if (( count < 0 )); then
(( NUMERIC = -count ))
zle ${WIDGET/forward/backward}
return
fi
while (( count-- )); do
match-words-by-style
# For some reason forward-word doesn't work like the other word
# commands; it skips whitespace only after any matched word
# characters.
if [[ -n $matched_words[4] ]]; then
# just skip the whitespace and the following word
word=$matched_words[4]$matched_words[5]
else
# skip the word but not the trailing whitespace
word=$matched_words[5]
fi
if [[ -n $word ]]; then
(( CURSOR += ${#word} ))
else
return 1
fi
done
return 0