mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Allow compressed man pages in help
It seems Fedora compresses our whopping 340k of man pages. Fixes #3130. Inspired by @TieDyedDevil's work there.
This commit is contained in:
parent
9d2092bf9f
commit
222a07e907
2 changed files with 11 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
||||||
function __fish_print_commands --description "Print a list of documented fish commands"
|
function __fish_print_commands --description "Print a list of documented fish commands"
|
||||||
if test -d $__fish_datadir/man/man1/
|
if test -d $__fish_datadir/man/man1/
|
||||||
find $__fish_datadir/man/man1/ -type f -name \*.1 -execdir basename '{}' .1 ';'
|
for file in $__fish_datadir/man/man1/**.1*
|
||||||
end
|
string replace -r '.*/' '' -- $file | string replace -r '.1(.gz)?$' ''
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
end
|
end
|
||||||
|
|
||||||
# Do nothing if the file does not exist
|
# Do nothing if the file does not exist
|
||||||
if not test -e "$__fish_datadir/man/man1/$item.1"
|
if not test -e "$__fish_datadir/man/man1/$item.1" -o -e "$__fish_datadir/man/man1/$item.1.gz"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,11 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
set cols (math $cols - 4) # leave a bit of space on the right
|
set cols (math $cols - 4) # leave a bit of space on the right
|
||||||
set rLL -rLL=$cols[1]n
|
set rLL -rLL=$cols[1]n
|
||||||
end
|
end
|
||||||
set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
if test -e "$__fish_datadir/man/man1/$item.1"
|
||||||
|
set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
||||||
|
else if test -e "$__fish_datadir/man/man1/$item.1.gz"
|
||||||
|
set help (gunzip -c "$__fish_datadir/man/man1/$item.1.gz" ^/dev/null | nroff -man -c -t $rLL ^/dev/null)
|
||||||
|
end
|
||||||
|
|
||||||
# The original implementation trimmed off the top 5 lines and bottom 3 lines
|
# The original implementation trimmed off the top 5 lines and bottom 3 lines
|
||||||
# from the nroff output. Perhaps that's reliable, but the magic numbers make
|
# from the nroff output. Perhaps that's reliable, but the magic numbers make
|
||||||
|
|
Loading…
Reference in a new issue