mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-20 18:41:16 -03:00
Process shell commands from bindings like regular char events
A long standing issue is that bindings cannot mix special input functions
and shell commands. For example,
bind x end-of-line "commandline -i x"
silently does nothing. Instead we have to do lift everything to shell commands
bind x "commandline -f end-of-line; commandline -i x"
for no good reason.
Additionally, there is a weird ordering difference between special input
functions and shell commands. Special input functions are pushed into the
the queue whereas shell commands are executed immediately.
This weird ordering means that the above "bind x" still doesn't work as
expected, because "commandline -i" is processed before "end-of-line".
Finally, this is all implemented via weird hack to allow recursive use of
a mutable reference to the reader state.
Fix all of this by processing shell commands the same as both special input
functions and regular chars. Hopefully this doesn't break anything.
Fixes #8186
Fixes #10360
Closes #9398
This commit is contained in:
@@ -32,7 +32,7 @@ To find out what sequence a key combination sends, you can use :doc:`fish_key_re
|
||||
``COMMAND`` can be any fish command, but it can also be one of a set of special input functions. These include functions for moving the cursor, operating on the kill-ring, performing tab completion, etc. Use ``bind --function-names`` or :ref:`see below <special-input-functions>` for a list of these input functions.
|
||||
|
||||
.. note::
|
||||
The commands must be entirely a sequence of special input functions (from ``bind -f``) or all shell script commands (i.e., valid fish script). To run special input functions from regular fish script, use ``commandline -f`` (see also :doc:`commandline <commandline>`). If a script produces output, it should finish by calling ``commandline -f repaint`` so that fish knows to redraw the prompt.
|
||||
If a script changes the commandline, it should finish by calling the ``repaint`` special input function.
|
||||
|
||||
If no ``SEQUENCE`` is provided, all bindings (or just the bindings in the given ``MODE``) are printed. If ``SEQUENCE`` is provided but no ``COMMAND``, just the binding matching that sequence is printed.
|
||||
|
||||
@@ -353,7 +353,7 @@ Turn on :ref:`vi key bindings <vi-mode>` and rebind :kbd:`Control`\ +\ :kbd:`C`
|
||||
|
||||
Launch ``git diff`` and repaint the commandline afterwards when :kbd:`Control`\ +\ :kbd:`G` is pressed::
|
||||
|
||||
bind \cg 'git diff; commandline -f repaint'
|
||||
bind \cg 'git diff' repaint
|
||||
|
||||
.. _cmd-bind-termlimits:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user