If you do:
bindkey | grep -F '^[x'
or simply:
bindkey '^[x'
or if in doubt about how to express Alt+x:
bindkey | grep -w x
You'll see:
"^[x" execute-named-cmd
That's the name of the widget bound to ESC x and most terminals send the ESC x character sequence upon pressing Alt+x
info zsh execute-named-cmd
Will tell you what that widget does (you may need to install the zsh-doc
package on some systems).
As the name suggests, it prompts for a command to execute. Commands here being zsh widgets, editor commands. That's the equivalent of emacs
' Meta-x, except that it's zsh editor commands instead of emacs
command (the command is called execute-extended-command
in emacs
)
For instance, if at that prompt, you type backward-delete-char
and press Return, it will invoke that widget which by default is bound to Backspace. You can do exactly the same in emacs
.
If instead, you type desc
Tab (Tab for completing it into describe-key-briefly
, a widget not bound to any key by default, and also found in emacs
) and press Return, you'll see another prompt:
$
Describe key briefly: _
Where you can press, say, Alt+x to see what that's bound do. You'd then get:
"^[x" is execute-named-cmd
If you do the same in emacs
, you'll see:
M-x runs the command execute-extended-command
To see the list of widgets, run zle -al
, zle -l
for the non-builtin ones, bindkey
to list the key bindings.
You can bind Alt+x to something else with
bindkey "^[x" some-widget