aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/down-or-search.fish
diff options
context:
space:
mode:
authorGravatar liljencrantz <liljencrantz@gmail.com>2007-09-22 00:05:49 +1000
committerGravatar liljencrantz <liljencrantz@gmail.com>2007-09-22 00:05:49 +1000
commitd2d397d9eb8ec9c4003d1ce45b26a7cc133e801f (patch)
tree61b8a13756c5f4978a79b5cb364f6b49d0edffea /share/functions/down-or-search.fish
parent607e97065958640f09dbe5de103bae0fd7c350c5 (diff)
Make up/down cursor move up or down when in multiline mode, except if already in search mode or at the top/bottom line. Since part of this is done in script-space, this involves adding some functionality to the commandline builtin.
darcs-hash:20070921140549-75c98-ba9e83f5e6fdecae5df8f83dd863794c6af9770c.gz
Diffstat (limited to 'share/functions/down-or-search.fish')
-rw-r--r--share/functions/down-or-search.fish23
1 files changed, 23 insertions, 0 deletions
diff --git a/share/functions/down-or-search.fish b/share/functions/down-or-search.fish
new file mode 100644
index 00000000..f8773666
--- /dev/null
+++ b/share/functions/down-or-search.fish
@@ -0,0 +1,23 @@
+function down-or-search
+ # If we are already in search mode, continue
+ if commandline --search-mode
+ commandline -f history-search-forward
+ return
+ end
+
+ # We are not in search mode.
+ # If we are on the bottom line, start search mode,
+ # otherwise move down
+ set lineno (commandline -L)
+ set line_count (commandline|wc -l)
+
+ echo on line $lineno of $line_count >&2
+
+ switch $lineno
+ case $line_count
+ commandline -f history-search-forward
+
+ case '*'
+ commandline -f down-line
+ end
+end