From 26051ea1984ee6f6329d46eb3c001a5d2bfe1bae Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sun, 28 Sep 2014 11:09:14 +0200 Subject: [PATCH] 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. --- doc_src/index.hdr.in | 2 +- share/functions/__fish_man_page.fish | 4 ++++ share/functions/fish_default_key_bindings.fish | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 share/functions/__fish_man_page.fish diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index fdceee1b2..4118cee86 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -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{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 bind builtin command. diff --git a/share/functions/__fish_man_page.fish b/share/functions/__fish_man_page.fish new file mode 100644 index 000000000..17a903153 --- /dev/null +++ b/share/functions/__fish_man_page.fish @@ -0,0 +1,4 @@ +function __fish_man_page + man (basename (commandline -po; echo)[1]) ^/dev/null + or printf \a +end diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index d33f7b53e..120a35731 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -111,8 +111,9 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis bind \ed forward-kill-word bind \ed kill-word - # Allow reading manpages by pressing F1 - bind $argv -k f1 'man (basename (commandline -po; echo)[1]) ^/dev/null; or echo -n \a' + # Allow reading manpages by pressing F1 (many GUI applications) or Alt+h (like in zsh) + 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 bind $argv \ep '__fish_paginate'