Search code examples
fish

Can fish shell's autosuggestion keybindings be customized?


There are two keybindings to accept a Fish suggestion: ctrl-f and right arrow. But these require using pinkies and/or leaving the home row.

I'd rather use something easier to access, like shift+enter. Is there a way to configure this? I couldn't find anything in the docs about changing the keybindings.


Solution

  • They can, by using the bind command. Use bind <sequence> <commands>, e.g. bind \cg accept-autosuggestion to bind it to control-g. Stick it somewhere in config.fish (assuming fish >= 3.0.0).

    To find out what sequence your terminal sends for a key combination (these sadly aren't standardized), use fish_key_reader and press that combination.

    To find out what commands are bound to a particular combo, use bind <sequence>. E.g. bind \cf will print bind --preset \cf forward-char (where --preset means that that's the default binding).

    However, shift+enter isn't typically possible, simply because it's not sent by the terminal, so it's unavailable to programs running in them.