2022-01-28 08:21:22 +08:00
|
|
|
function down-or-search -d "search forward or move down 1 line"
|
2016-11-28 13:27:22 +08:00
|
|
|
# If we are already in search mode, continue
|
|
|
|
if commandline --search-mode
|
|
|
|
commandline -f history-search-forward
|
|
|
|
return
|
|
|
|
end
|
2007-09-21 22:05:49 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# If we are navigating the pager, then up always navigates
|
|
|
|
if commandline --paging-mode
|
|
|
|
commandline -f down-line
|
|
|
|
return
|
|
|
|
end
|
2014-01-26 07:32:13 +08:00
|
|
|
|
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# We are not already in search mode.
|
|
|
|
# If we are on the bottom line, start search mode,
|
|
|
|
# otherwise move down
|
2020-05-15 13:56:06 +08:00
|
|
|
set -l lineno (commandline -L)
|
|
|
|
set -l line_count (count (commandline))
|
2007-09-21 22:05:49 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
switch $lineno
|
|
|
|
case $line_count
|
|
|
|
commandline -f history-search-forward
|
2010-09-18 10:18:26 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
case '*'
|
|
|
|
commandline -f down-line
|
|
|
|
end
|
2007-09-21 22:05:49 +08:00
|
|
|
end
|