Bind shift-tab to complete-backward in fish

14

7

I found myself using the auto-complete functionality of the fish-shell, where pressing tab twice or more cycles through the suggestions. But then I accidentaly pressed tab once to many, and I wanted to go back to the previous suggestion, so I pressed shift-tab, which only appended [z to the command.

For example, when I type cd Dtabtab:

~> cd Desktop/

I press tab, result:

~> cd Documents/

Now when I press <shift+tab>, the prompt changes to ~> cd Documents/[Z instead of returning to the desired:

~> cd Desktop/

How do I do this (preferably using the fish_user_key_bindings.fish file)? The documentation only provides the special function complete.

Sebastian

Posted 2013-11-05T15:22:47.570

Reputation: 243

Is there not an "undo" or anything? – Josh Stevenson – 2015-05-12T12:41:31.527

Answers

1

  • As you said "The documentation only provides the special function complete" . you can't go back to previews suggestion because this feature isn't implemented .

  • but for defining a new binding you have to use fish_user_key_binding function NOT .fish file : open your configuration file ~/.config/fish/config.fish

and add :

function fish_user_key_bindings
        bind [Z complete
        end
  • restart your fish , this well bind shift+tab for complete

Ahed Eid

Posted 2013-11-05T15:22:47.570

Reputation: 792

I don't need another keybinding for complete, I need a keybinding to go back to the previous suggestion. I guess you're right and it just isn't implemented... – Sebastian – 2014-06-29T19:13:36.153

-2

Consider using zsh instead.

The exact details of its autocompleter are of course configurable to your personal tastes, but the way I have it set up is if I press Tab twice, I get a "menu" that I can navigate using the Tab key or the arrow keys, like so:

ZSH Completion

Once I've selected the entry I want, I can press Enter to tell zsh this is what I want, or I can just continue typing and zsh will assume that's correct.

Nicholas O'Connor

Posted 2013-11-05T15:22:47.570

Reputation: 37