Fish programming: why the `bind` commands in config.fish are not executed?

At the end of /usr/share/fish/config.fish , I have the following commands:

 bind \e\[1\;5C forward-word bind \e\[1\;5D backward-word echo foo 

Then I launch the fish, it prints "foo". Then I run bind to print a list of all the keyboard shortcuts, but there are no forward-word or back-word entries on the bind output.

Did I miss something?

+4
source share
2 answers

Since these key bindings are already defined in fish_default_key_bindings, I assume that the problem is with your terminal emulator and that it does not send the correct escape sequence.

You also do not have to edit the global configuration of /usr/share/fish/config.fish . Your custom configuration is in ~/.config/fish/config.fish

If you want to specify your own key bindings, this must be done inside the fish_user_key_bindings function.

You can do this manually by editing: ~/.config/fish/functions/fish_user_key_bindings.fish .

Or use the provided tools:

If the function does not exist, you can do:

 function fish_user_key_bindings bind \e\[1\;5C forward-word bind \e\[1\;5D backward-word end funcsave fish_user_key_bindings 

Or, if you already have a function:

 funced fish_user_key_bindings funcsave fish_user_key_bindings 

Edit:

The reason you cannot specify them in your configuration is because they are below reset, here in fish_default_key_bindings .

+11
source

Just enter this internal function called fish_user_key_bindings in config.fish

 function fish_user_key_bindings bind \e\[1\;5C forward-word bind \e\[1\;5D backward-word end 
+5
source

Source: https://habr.com/ru/post/1481852/


All Articles