Zsh has the following keyboard shortcut for Man
Esc+h
I would like to have a similar keyboard shortcut for info such as
Esc+i
How can you make such a keyboard shortcut for Info?
You can create a keyboard shortcut to open a terminal window, create a new shortcut, press the super key and search for “keyboard” or “shortcut” and launch it. Click on “+” option at the end of the list to create a new keyboard shortcut. Provide the required information, Like Name of the shortcut, command.
Insert a Text boxPress and release ALT, N, and then press X. Press the arrow keys to select the Text box that you want, and then press ENTER. Type the text that you want.
Control-D: Delete the character to the right of the insertion point. Or use Fn-Delete. Fn-Delete: Forward delete on keyboards that don't have a Forward Delete key.
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 cut'n paste that into a shell to try it out, and add to your .zshrc for permanent effect.
To paraphrase the code: the general idea is that we first define a widget called "run_info", implemented with a function with the same name. It takes the command line buffer and adds "info " to the beginning. Then it accepts the command line (same as pressing Enter). Finally, the widget is mapped to the keyboard shortcut.
You can read the zshzle(1) man page for more info on how this stuff works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With