When I type Alt-x
, execute:
will pop up:
~ %
execute: _
And I can continue type(space has no effect):
~ %
execute: what'sthis
Q1: what's this promotion for?
Q2: How can i modify this shortcut to other key-binding? Because M-x
in emacs is quite useful, and i use shell in emacs often, so the two conflict.
I have google for hours, but still have no answers(maybe my keywords are not correct–google: "zsh" + "excute:", "google: zsh keybinding bindkey
Best Answer
If you do:
or simply:
or if in doubt about how to express Alt+x:
You'll see:
That's the name of the widget bound to ESC x and most terminals send the ESC x character sequence upon pressing Alt+x
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 ofemacs
command (the command is calledexecute-extended-command
inemacs
)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 inemacs
.If instead, you type
desc
Tab (Tab for completing it intodescribe-key-briefly
, a widget not bound to any key by default, and also found inemacs
) and press Return, you'll see another prompt:Where you can press, say, Alt+x to see what that's bound do. You'd then get:
If you do the same in
emacs
, you'll see: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