Make keyboard shortcut for Info in Zsh?

Zsh has the following keyboard shortcuts for Man

Esc + h

I would like to have a similar key combination for information such as

Esc + i

How can you make this keyboard shortcut for Info?

+4
source share
1 answer

This should do the trick:

function run_info() { # Prepend "info" to the command line and run it. BUFFER="info $BUFFER" zle accept-line } # Define a widget called "run_info", mapped to our function above. zle -N run_info # Bind it to ESC-i. bindkey "^[i" run_info 

Just paste this into your shell to try it out and add a permanent effect to your .zshrc.

To rephrase the code: the general idea is that we first define a widget called "run_info" implemented using a function with the same name. It takes a command line buffer and adds "info" to the beginning. Then it accepts the command line (similar to pressing Enter ). Finally, the widget is displayed on the keyboard.

You can read the zshzle (1) man page for more information on how this works.

+11
source

All Articles