about summary refs log tree commit diff
path: root/Functions/Zle/up-line-or-beginning-search
diff options
context:
space:
mode:
Diffstat (limited to 'Functions/Zle/up-line-or-beginning-search')
-rw-r--r--Functions/Zle/up-line-or-beginning-search13
1 files changed, 13 insertions, 0 deletions
diff --git a/Functions/Zle/up-line-or-beginning-search b/Functions/Zle/up-line-or-beginning-search
new file mode 100644
index 000000000..12f2edaae
--- /dev/null
+++ b/Functions/Zle/up-line-or-beginning-search
@@ -0,0 +1,13 @@
+# Like up-line-or-search, but uses the whole line prefix up to the
+# cursor position for searching backwards.
+
+if [[ $LASTWIDGET != $WIDGET ]]
+then
+    if [[ $LBUFFER == *$'\n'* ]]
+    then
+        __last_up_line=up-line-or-history
+    else
+        __last_up_line=history-beginning-search-backward
+    fi
+fi
+zle .${__last_up_line:-beep}