2002-03-05 17:33:19 +01:00
|
|
|
# Copy the word before the one you last copied --- call repeatedly
|
|
|
|
# to cycle through the list of words on the history line.
|
|
|
|
#
|
|
|
|
# Words in combination with insert-last-word to use the line reached,
|
|
|
|
# and start from the word before last. Otherwise, it will operate on
|
|
|
|
# the current line.
|
|
|
|
|
2003-01-27 17:41:15 +01:00
|
|
|
emulate -L zsh
|
2008-07-07 11:15:44 +02:00
|
|
|
setopt typesetsilent
|
2003-01-27 17:41:15 +01:00
|
|
|
|
2008-07-07 11:15:44 +02:00
|
|
|
typeset -g __copyword
|
2002-03-05 17:33:19 +01:00
|
|
|
if (( ${NUMERIC:-0} )); then
|
2003-01-27 17:41:15 +01:00
|
|
|
# 1 means last word, 2 second last, etc.
|
|
|
|
(( __copyword = ${NUMERIC:-0} ))
|
|
|
|
zstyle -s :$WIDGET widget __copywidget
|
2002-03-05 17:33:19 +01:00
|
|
|
elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then
|
|
|
|
(( __copyword-- ))
|
|
|
|
elif [[ $LASTWIDGET = *insert-last-word ]]; then
|
|
|
|
__copyword=-2
|
2008-07-07 11:15:44 +02:00
|
|
|
typeset -g __copywidget=$LASTWIDGET
|
2002-03-05 17:33:19 +01:00
|
|
|
else
|
|
|
|
__copyword=-1
|
2003-01-27 17:41:15 +01:00
|
|
|
zstyle -s :$WIDGET widget __copywidget
|
2002-03-05 17:33:19 +01:00
|
|
|
fi
|
|
|
|
|
2003-01-27 17:41:15 +01:00
|
|
|
zle ${__copywidget:-.insert-last-word} 0 $__copyword
|