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 : ?

  • What shell are you using? bash, zsh, etc.?
    – Abdul
    Commented Jul 14, 2017 at 4:32
  • @Abdul I am using bash
    – vdegenne
    Commented Jul 14, 2017 at 9:26
  • If you remember what you are looking for, you can do something like 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 also grcat superuser.com/questions/602294/… . And if you want an automagical tool for it, you can try history | fzf github.com/junegunn/fzf . None of these uses Ctrl-R, so it's not posted as an answer.
    – Joe
    Commented Jul 15, 2017 at 9:11
  • Hey @Joe, fzf sets up a Ctrl-R binding for the shell when you run it's install script, effectively replacing the built in reverse-i-search. It colors the search prompt in the exact way OP wanted, so threre's that ;) Commented May 29, 2018 at 16:48

1 Answer 1


As https://unix.stackexchange.com/a/352377 suggests, you will have to change source code to do this. Current versions of Bash (up to and including recently released 5.0) can color only filename completion suggestions; i-search always outputs plain text.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .