mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Show manpage for command under cursor
This commit lets you check the manpage for a leading command by moving the cursor over it, matching the behavior of tab complete. It also lets you select the man page for the base of a two-part command like `string match`. The additional regex case is added because `commandline -t` returns an empty string when the cursor is after a space, e.g. at the end of 'sudo ', which the later checks don't handle. This diagram shows the manpage picked for different cursor positions: > sudo -Es time git commit -m foo +-------++---++--++------------+ | || || || | | || || |+------------+ | || || | git-commit | || |+--+ | || | git | |+---+ | | time +-------+ sudo
This commit is contained in:
parent
42a9dfa08a
commit
a605bcb830
1 changed files with 2 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
function __fish_man_page
|
||||
# Get all commandline tokens not starting with "-"
|
||||
set -l args (commandline -po | string match -rv '^-')
|
||||
# Get all commandline tokens not starting with "-", up to and including the cursor's
|
||||
set -l args (string match -rv '^-|^$' -- (commandline -cpo && commandline -t))
|
||||
|
||||
# If commandline is empty, exit.
|
||||
if not set -q args[1]
|
||||
|
|
Loading…
Reference in a new issue