Skip to content

Linux Shell Incremental Search

You probably use (and rely) on command search a lot already but thought I would add something about fish. If you are from the csh or ksh days you will recall the big adoption for bash came because of up and down scroll through command and maybe to a lesser extent tab for showing completion options.

I recently started using fish in some places. I know zsh has become popular as a bash alternative and zsh has the same powerful history search Control-R functionality.

Unfortunately with fish it is handled different. Many people prefer the way fish handles it and I admit I really like the type ahead and showing it in lighter color like shown below.

There are an ongoing push to also add Control-R search like bash and zsh handles it. As far as I can tell in v3.3.1 which is in the latest Ubuntu 22.04 beta this is not working as I wanted.

Note

With fish you start typing and you can still then use up and down keys to get through a list of related searches. I like and dislike the way fish does it. For the moment I am still mostly going back to bash since zsh also annoys me(for other reasons). But I could end up with fish if they leave the type ahead like it is and add exact Control-R incremental search like bash and zsh.

Powerful History Mechanism of fish

Modern shells save previous commands in a command history. You can view earlier commands by using the up and down arrows. Fish extends this concept by integrating the history search functionality. To search the history, simply type in the search string, and press the up arrow. By using the up and down arrow, you can search for older and newer matches. The fish history automatically removes duplicate matches and the matching substring is highlighted. These features make searching and reusing previous commands much faster.

Good explanation for why fish search is not Control-R

Using up and down arrows it's not a good alternative to Ctrl+R, because if the phrase you are looking for it is really deep in the history, you'll have to hit up/down keys a lot! I just use history | grep -i [phrase]