When I use the reverse search functionality of bash, oftentimes it gets stuck after entering a single symbol. For example, if my history is:
username dir$ scala -version
username dir$ git status
and then I press Ctrl + R
and type in s
, it gets stuck at
(reverse-i-search)`s': git status
Typing further symbols does nothing. Any idea on why does that happen?
Some information that might be relevant:
PS1:
\u \[\033[0;35m\]\W\[\033[0;37m\]$
bash version:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
Copyright (C) 2007 Free Software Foundation, Inc.
OS:
macOS High Sierra Version 10.13.2
Terminal:
iTerm2
Best Answer
Because the search program found the
s
at end of... status
and is now looking for another command that also ends with... status
, which is does not find.You can confirm this theory using
<ctrl-R> + d
instead of<ctrl-R> + s
. Then the search will find thed
ofusername d
, and will continue the search from there, and e.g. will straightforwardly go "up" tousername dir$ scala -version
.