简体   繁体   中英

Remove preset binding in fish shell

I am unable to remove the default binding in Fish shell for CTRL + p .

I want to activate separate "background" app outside of the terminal using the CTRL+P shortcut.

I have tried:

bind --erase \cp up-or-search

However the binding remains. How can I remove the preset bindings? The documentation does not mention it.

I want this shortcut to propagate up to the parent process rather than Fish swallowing it and reacting to it.

That's not how it works.

If by "parent process" you mean the terminal, that gets first dibs on every key. It gets to decide what is passed on and what isn't.

If by "parent process" you mean an in-terminal process that started fish: That typically stays in the background and doesn't read any keys at all.

And fish will (and has to) read all input it receives, even if it then decides to do nothing. Reading it is how it finds out what it has to do, and it cannot stuff the input back.

And the terminal has no idea what the processes running inside it have bound or not, so it also can't decide to send keys that it knows the shell will do something with and keep others for itself.

Your mental model is incorrect.

How can I remove the preset bindings?

To erase a preset binding, you could run

bind --erase --preset \cp

However, you would have to arrange for that to be run after the binding has actually been set up. You might want to store it in a function called fish_user_key_bindings . Fish runs that after it sets up the bindings, whenever it does it (eg if you switch to vi-mode it'll rerun it).

Typically to disable a binding you would rather make your own that does nothing, like

bind \cp true

Not that this would help what you want to do, see above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM