ctrl-x N, N element [0,9]
### jump behind the Nth word on the cmdline.
function jump_after_wordN() {
setopt localoptions noksharrays extendedglob
local words
local -i i num=$1
(( num == 0 )) && (( num = 10 ))
words=(${(z)BUFFER})
if (( ${#words} <= num )) ; then
CURSOR=${#BUFFER}
else
if (( num == 1 )) ; then
CURSOR=${#${words[${num}]}}
return
fi
(( CURSOR = 1 ))
for (( i = 1 ; i <= num ; ++i )) ; do
(( CURSOR += ${#${words[$(( i ))]}} ))
(( i == num )) && break
while [[ ${BUFFER[$(( CURSOR + 1 ))]} == [[:space:]] ]] ; do
(( CURSOR++ ))
done
done
fi
}
for i in {0..9} ; do
eval "function jump_after_word${i} () { jump_after_wordN ${i} }"
done
zle -N jump_after_wordN
for i in {0..9} ; do
zle -N jump_after_word${i}
bindkey '^x'${i} jump_after_word${i}
done
Siehe: ~/etc/zsh/zfunct und ~/etc/zsh/zle
(Comments: 0)