Search forward in command line history
Solution 1
Bash also has a forward history search, which is mapped to CtrlS.
Often, this shortcut will be masked by the stop
flow control key binding for the terminal (check with stty -a
). This will make your terminal stop outputting anything—not quite what you want.
To get forward history search working, you have two options:
Disable the flow control altogether:
stty -ixon
Bind flow control to something else, e.g. to CtrlX with
stty stop ^X
Solution 2
Ctrl + S should search the history "forward". Or whatever bind -p
tells you is bound to forward-search-history
.
Related videos on Youtube
j1b3
CTO in a Mobile Marketing Company (Web Ads, SMS, App dev ...)
Updated on September 18, 2022Comments
-
j1b3 over 1 year
With Ctrl + R you can search in previous commands. If you hit Ctrl + R again, it will displays older previous commands. The problem it that this search is "one way", it always displays older results each time you press Ctrl + R.
Right now, if I hit Ctrl+R too many times and miss the result I was actually looking for, I have to stop my search (Ctrl + G) and restart it from the beginning.
Is there any command (Ctrl + something ) to search for "newer" results than the one currently displayed?