bash history CTRL+R behaviour [closed]
-
30-06-2021 - |
Question
Sometimes I try to search some command by CTRL+R and it's not found, while I recently used it or search by CTRL+R with success.
Afer I run `history I'm able to find the command again.
Is this behavior is normal? How it can be changed?
Solution
Ctrl+R searches backward from the current position in the history, so if you already moved that position you'll miss the parts toward the end.
e.g.:
themel@kallisti: ~ $ foob
bash: foob: command not found
themel@kallisti: ~ $ barz
bash: barz: command not found
themel@kallisti: ~ $ barq
bash: barq: command not found
themel@kallisti: ~ $ quarg
bash: quarg: command not found
Ctrl+R,bar yields:
(reverse-i-search)`bar': barq
but also moves to that point in history - if you subsequently do Ctrl+R and search for quarg
, you won't find it. This is reset by remedied by using end-of-history
(M-> by default) to re-set the index.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow