6

Comming from this page with information on how to customize zsh I encounter this

# oh wow!  This is killer...  try it!
bindkey -M vicmd "q" push-line

I'm not able to find a man page for bindkey, nor understanding what is the key being binded, what does -M means and what is vicmd.

So I've no idea how to know whats the beautifier killer feature :)

0

1 Answer 1

7
% type bindkey
bindkey is a shell builtin

So its documentation is in the zsh manual, not in a man page of its own. Although there's a man zshbuiltins, the bindkey builtin is not documented there because it's part of a semi-autonomous piece of zsh, the line editor zle, and so it's documented in man zshzle.

You can find the documentation by running run-help bindkey in zsh, or pressing M-h while the cursor is on a bindkey command. This requires run-help to be properly set up, which for some reason is not the case by default: it's an alias to man. To get a useful run-help, put these lines in your .zshrc:

unalias run-help 2>/dev/null
autoload -U run-help

Alternatively, use man zshall. Or if you're browsing a hypertext version of the manual, use the functions index, which also lists builtins.


vicmd is the keymap used in vi command mode. push-line is an editor widget, which have their own index. So this command makes q “pause” the current line in vi command mode (for some reason this feature, which is indeed useful, is only bound to a key by default in emacs mode).

2
  • I upgraded omz yesterday. I put unalias run-help in my .zshrc (the line after source $ZSH/oh-my-zsh.sh) and it gave me this error: /home/dan/.zshrc:unalias:86: no such hash table element: run-help. That might mean you don't need to do that step anymore. But when I run run-help bindkey, it prints two lines: bindkey\n See the section `Zle Builtins' in zshzle(1). Is that what I'm supposed to see? Sep 15, 2023 at 20:46
  • @DanielKaplan zsh defines an alias called run-help by default, but I guess recent versions of omz remove the alias. Calling unalias on an alias that doesn't exist is harmless except for the annoying error message, so I've edited my answer to suppress that message. As for the documentation of bindkey, indeed run-help is unfortunately not smart enough to see that it's just a cross-reference to another part of the manual and it should show the content of that part. Sep 16, 2023 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .