Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Is there a “reverse incremental search” functionality in Fish similar to Bash’s CTRL+R?

Writer Matthew Barrera

I’m really impressed with Fish’s autocomplete functionality. However there is one feature in Bash that I’m unable to find in Fish. When you press Ctrl+R in Bash and begin to type out a term, a search is done on your .bash_history to find matches in reverse order.

Is there a similar functionality in Fish?

2

8 Answers

I've never used fish myself but a cursory google search brought up this page which states that

Powerful History Mechanism

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.

Is that what you are looking for? It seems quite similar to bash's.

0

fish doesn't implement incremental history search, although it seems to come up fromtime to time. The pre-2.0 documentation has a "Missing features and bugs" section 1 which lists incremental history search fairly far down in the "Possible features" list. The fish-users mailing list includes this message from Axel Liljencratz, dated August 21, 2006, in which he says that incremental search would be a nice feature to have.

If you're used to bash-style incremental search, fish history searching does take a bit of getting used to. You have to type the search term first, and you move up and down matching entries with up- and down- arrow. But I suppose you get used to it.

You can use :

this library provide powerful search for fish shell.

There is a feature request opened in the fish bug tracker:

Someone already implemented a workaround for this:

Far better Ctrl+r reverse searches with FZF and fzf fish plugin, using the Triton fish package manager, configured to use The Silver Searcher.

~/.config/fish/config.fish:

triton jethrokuan/fzf
set -U FZF_COMPLETE 2
set -U FZF_FIND_FILE_COMMAND "ag -l --hidden --ignore .git"
set -U FZF_DEFAULT_OPTS "--height 40% --layout=reverse --border"

On Mac OS, to install the prereqs:

brew install the_silver_searcher
brew install fzf

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]

instead of ctrl + R you can use ctrl + shift + tab just after you type the first part you wanted to search:enter image description here

You can use peco in FISHELL as your reverse-i-serach. You have to make abbreviations in your config.fish file in /home/user/.config/fish/ Directory

I am using abbr rr "history | peco" and then if i type rr -> enter im in history-search. But i have problem right now.. If I search for string in history and type enter it does not do anything :/

EDIT: Okay I was searching web for the solution of executable peco history and i found this website -

Just follow the directions and put it into your config.fish file

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy