Add Meta+H as keybinding for man page.

Apparently, in zsh, Meta+H can be used to display the manpage for
the current command. This commit adds this zsh feature to fish shell.

The F1 keybinding is left, although it's now secondary according to
fish help, as some terminal emulators don't let the user press F1 key.
This commit is contained in:
Konrad Borowski 2014-09-28 11:09:14 +02:00
parent b00cbae4b5
commit 26051ea198
3 changed files with 8 additions and 3 deletions

View file

@ -896,7 +896,7 @@ Similar to bash, fish has Emacs and Vi editing modes. The default editing mode i
- @key{Alt,U} makes the current word uppercase. - @key{Alt,U} makes the current word uppercase.
- @key{F1} shows the manual page for the current command, if one exists. - @key{Alt,H} (or @key{F1}) shows the manual page for the current command, if one exists.
You can change these key bindings using the <a href="commands.html#bind">bind</a> builtin command. You can change these key bindings using the <a href="commands.html#bind">bind</a> builtin command.

View file

@ -0,0 +1,4 @@
function __fish_man_page
man (basename (commandline -po; echo)[1]) ^/dev/null
or printf \a
end

View file

@ -111,8 +111,9 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
bind \ed forward-kill-word bind \ed forward-kill-word
bind \ed kill-word bind \ed kill-word
# Allow reading manpages by pressing F1 # Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh)
bind $argv -k f1 'man (basename (commandline -po; echo)[1]) ^/dev/null; or echo -n \a' bind $argv -k f1 __fish_man_page
bind $argv \eh __fish_man_page
# This will make sure the output of the current command is paged using the less pager when you press Meta-p # This will make sure the output of the current command is paged using the less pager when you press Meta-p
bind $argv \ep '__fish_paginate' bind $argv \ep '__fish_paginate'