2

Fish is a great shell (the best?) but its completion interface has a particular quirk that I personally don't like and would like to disable. It's expressed by this sentence in the tutorial:

Hit tab again to cycle through the possibilities.

This means that, after hitting tab to complete the longest common prefix (behavior A) and showing a menu of further entries, if you hit Tab again you start cycling through the entries (behavior B).

If there a way to disable behavior B of the Tab key, or bind it to a different key, while keeping behavior A?

3

In the fish shell, tab will complete the common prefix unless the common prefix is empty, in which case it will start the pager. This particular behavior is not configurable.

The pager has lots of ways to navigate inside it:

  1. Use tab for next, shift-tab for previous
  2. Use the arrow keys to move in cardinal directions
  3. Press control-S to reveal a search field for further filtering
  4. Escape to cancel, putting you back from before triggering the pager

Escape (via the cancel binding) saves you from needing to backspace if you change your mind.

It is possible to replace the default behavior of tab. For example to make tab do nothing if the pager is visible:

 bind \t 'if not status -P ; commandline -f complete; end'

This says "if the pager is not shown, then perform the 'complete' readline function".

| improve this answer | |
  • Thank you! I didn't know about the escape = cancel key, it's very useful. Where can I find a list of all key bindings related to the pager? Can I disable the Tab / Shift Tab bindings of the pager, the ones that select the next / previous entries, while keeping the main Tab binding outside the pager, the one that triggers autocompletion? – Tobia Feb 1 at 9:41
  • There's also page up and page down; I think that makes the list exhaustive. We haven't documented the pager navigation. I edited my answer to show one way of conditionalizing the tab behavior. – ridiculous_fish Feb 2 at 20:05
  • That would be great, if I could make tab do nothing if the pager is visible. But I cannot get your command to work: status -P gives me an error (I tried both in Fish 2 and 3) Also what is the difference between commandline -f complete and just complete, which is the default command bound to \t? – Tobia Feb 3 at 0:43
  • @Tobia this particular feature bugs me as well. Have you found a way to make this disabler work? – Tom Trebicky May 9 at 19:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.