On Tue, Sep 20, 2016, at 03:44 AM, Jonathan R. Williford wrote:
> Typing "bar" and then up-arrow will scroll through the history of commands 
> that contain "bar", including "foobar". Is there a way to scroll through the 
> history of commands that start with "bar", excluding commands like "foobar" 
> that does not start with "bar"?
> 
> If there is not a built in key-combination for this, is there a way to add 
> one through the config.fish or other configuration files? It looks like the 
> following almost does what I want:
> 
> bind "[1;5A" history-search-backward
> bind "[1;5B" history-search-forward
> 
> which binds the Ctrl+Up-Arrow and Ctrl+Down-Arrow to the respective commands, 
> however, they move the cursor to the end of the line. Hence, it works for the 
> first key stroke, but the search string changes for consecutive key strokes.
> 
> Thanks,
> Jonathan R. Williford

It looks like what you want is for fish to do a history search
considering only matches at the beginning of the command (called a
prefix search in fish land).  The default behavior for fish seems to be
a substring search, rather than a prefix search.  I don't know of any
fish function that can be bound to a keystroke to make this happen. 
Maybe such a function could be written?

However, there is the --prefix option to the history command, which you
might find useful.

If you want this feature to be added to fish, you can open an issue on
its github page at https://github.com/fish-shell/fish-shell/issues. 
Someone more familiar with fish than me might even provide a function to
achieve what you want, if it's possible.

------------------------------------------------------------------------------
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to