I am using fedora 25 but I think this is a general behavior on unix system.
When I ctrl+r
in a command-line environment I can start to type in and anything I type will get to be matched backward in the invoked command history of the current user. This helps a lot to rapidly find a command and not type it again.
I like to optimize when it comes to my environment, but sometimes when I am fast I found the prompt a bit confusing because everything is white, for instance if I type find
during the reverse-i-search, the prompt will output something like that,
(reverse-i-search)`find': find . -type f -name '*.h'
Is there a way to color the part before :
?
history | grep 'pattern'
and then type a!nnn
, where nnn is the command number listed by history. If you still want color, see stackoverflow.com/questions/20909942/…. There's alsogrcat
superuser.com/questions/602294/… . And if you want an automagical tool for it, you can tryhistory | fzf
github.com/junegunn/fzf . None of these usesCtrl-R
, so it's not posted as an answer. – Joe Jul 15 '17 at 9:11fzf
sets up aCtrl-R
binding for the shell when you run it's install script, effectively replacing the built inreverse-i-search
. It colors the search prompt in the exact way OP wanted, so threre's that ;) – Wiesław Herr May 29 '18 at 16:48