2006-11-18 00:24:38 +08:00
|
|
|
|
2006-11-20 07:27:34 +08:00
|
|
|
function __fish_print_help -d (N_ "Print help message for the specified fish function or builtin")
|
|
|
|
|
|
|
|
# These two expressions take care of underlines (Should be italic)
|
|
|
|
set -l cmd1 s/_\x08'\(.\)'/(set_color --underline)\\1(set_color normal)/g
|
|
|
|
set -l cmd2 s/'\(.\)'\x08_/(set_color --underline)\\1(set_color normal)/g
|
|
|
|
|
|
|
|
# This expression should take care of bold characters. It's not
|
2006-11-20 21:14:12 +08:00
|
|
|
# waterproof, since it doesn't check that the same character is
|
|
|
|
# used both before and after the backspace, since regular
|
|
|
|
# languages don't allow backreferences.
|
2006-11-20 07:27:34 +08:00
|
|
|
set -l cmd3 s/.\x08'\(.\)'/(set_color --bold)\\1(set_color normal)/g
|
|
|
|
|
|
|
|
# Combine all expressions in a single variable
|
|
|
|
set -l sed_cmd -e $cmd1 -e $cmd2 -e $cmd3
|
|
|
|
|
|
|
|
# Render help output, save output into the variable 'help'
|
2006-11-18 00:24:38 +08:00
|
|
|
set -l help (nroff -man $__fish_datadir/man/$argv.1)
|
|
|
|
set -l lines (count $help)
|
2006-11-20 07:27:34 +08:00
|
|
|
|
|
|
|
# Print an empty line first
|
2006-11-18 00:24:38 +08:00
|
|
|
echo
|
2006-11-20 07:27:34 +08:00
|
|
|
|
|
|
|
# Filter and print help
|
2006-11-20 21:14:12 +08:00
|
|
|
printf "%s\n" $help| tail -n (expr $lines - 5) | head -n (expr $lines - 8) | sed $sed_cmd
|
2006-11-20 07:27:34 +08:00
|
|
|
|
2006-11-18 00:24:38 +08:00
|
|
|
end
|