summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-03-05 16:33:19 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-03-05 16:33:19 +0000
commit849f4068de9831fdaa635c2372dada9131fb5a39 (patch)
treeb1d1696df228fc9c34412920f74d03e1794eba8b /Functions
parent15630b234ad7d2e91b165ba0bf584ee0e6e6efce (diff)
downloadzsh-849f4068de9831fdaa635c2372dada9131fb5a39.tar.gz
zsh-849f4068de9831fdaa635c2372dada9131fb5a39.tar.xz
zsh-849f4068de9831fdaa635c2372dada9131fb5a39.zip
16767: Src/Zle/zle_hist.c, Doc/Zsh/zle.yo, Doc/Zsh/contrib.yo,
Functions/Zle/copy-earlier-word:  Enhance insert-last-word to
pick different lines from the history (including the current
line) and different words from that line.  Add copy-earlier-word
as suggested by Dominik Vogt to copy words from either the
current line, or (following an insert-last-word) a previous
history line.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Zle/copy-earlier-word19
1 files changed, 19 insertions, 0 deletions
diff --git a/Functions/Zle/copy-earlier-word b/Functions/Zle/copy-earlier-word
new file mode 100644
index 000000000..bbc8af35c
--- /dev/null
+++ b/Functions/Zle/copy-earlier-word
@@ -0,0 +1,19 @@
+# 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.
+
+if (( ${NUMERIC:-0} )); then
+   # 1 means last word, 2 second last, etc.
+   (( __copyword = ${NUMERIC:-0} ))
+elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then
+  (( __copyword-- ))
+elif [[ $LASTWIDGET = *insert-last-word ]]; then
+  __copyword=-2
+else
+  __copyword=-1
+fi
+
+zle .insert-last-word 0 $__copyword