mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 11:21:15 -03:00
share: share logic between standalone and installed builds
This commit is contained in:
@@ -70,9 +70,8 @@ function __fish_complete_man
|
||||
|
||||
# Fish commands are not given by apropos
|
||||
if not set -ql exclude_fish_commands
|
||||
set -l files $__fish_data_dir/man/man1/*.1*
|
||||
string replace -r '.*/([^/]+)\.1(\.gz)?$' '$1\t1: fish command' \
|
||||
-- $files (status list-files man/man1/ 2>/dev/null)
|
||||
__fish_data_list_files man/man1 |
|
||||
string replace -rf '.*/([^/]+)\.1(\.gz)?$' '$1\t1: fish command'
|
||||
end
|
||||
else
|
||||
return 1
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
# localization: skip(private)
|
||||
function __fish_print_commands --description "Print a list of documented fish commands"
|
||||
if set -q __fish_data_dir[1] && test -d $__fish_data_dir/man/man1/
|
||||
printf %s\n $__fish_data_dir/man/man1/**.1*
|
||||
else
|
||||
status list-files man/man1/ 2>/dev/null
|
||||
end |
|
||||
__fish_data_list_files man/man1 |
|
||||
string replace -r '.*/' '' |
|
||||
string replace -r '.1(.gz)?$' '' |
|
||||
string match -rv '^fish-(?:changelog|completions|doc|tutorial|faq|for-bash-users|interactive|language|releasenotes|terminal-compatibility)$'
|
||||
|
||||
@@ -19,26 +19,19 @@ function __fish_print_help --description "Print help for the specified fish func
|
||||
return
|
||||
end
|
||||
|
||||
# NOTE: this is duplicated with share/functions/man.fish, but that
|
||||
# function is not always defined.
|
||||
set -l tmpdir
|
||||
set -l file (path filter -- \
|
||||
$__fish_data_dir/man/man1/$item.1 \
|
||||
$__fish_data_dir/man/man1/$item.1.gz)
|
||||
or begin
|
||||
set -l contents "$(status get-file man/man1/$item.1)"
|
||||
or return 2
|
||||
set tmpdir (__fish_mktemp_relative -d fish-print-help)
|
||||
or return
|
||||
set file $tmpdir/$item.1
|
||||
printf %s\n $contents >$file
|
||||
function __fish_print_help_man -V item -a man1
|
||||
if not path is $man1
|
||||
# Trigger the "documentation not be installed" message. Currently
|
||||
# only when called from core.
|
||||
return 2
|
||||
end
|
||||
set -l file (path filter -- $man1/$item.1 $man1/$item.1.gz)
|
||||
command man $file[1]
|
||||
end
|
||||
command man $file[1]
|
||||
set -l saved_status $status
|
||||
if set -q tmpdir[1]
|
||||
command rm -r $tmpdir
|
||||
end
|
||||
return $saved_status
|
||||
__fish_data_with_directory man/man1 \
|
||||
"$(string escape --style=regex $item.1)(?:\.gz)?" \
|
||||
__fish_print_help_man
|
||||
__fish_with_status functions --erase __fish_print_help_man
|
||||
end
|
||||
|
||||
function __fish_print_help_pre_4.1 --description "Print help message for the specified fish function or builtin"
|
||||
|
||||
@@ -57,20 +57,15 @@ function man
|
||||
end
|
||||
end
|
||||
|
||||
set -l tmpdir
|
||||
if not set -q argv[2] && status list-files "man/man1/$argv[1].1" &>/dev/null
|
||||
set tmpdir (__fish_mktemp_relative -d fish-man)
|
||||
or return
|
||||
status get-file "man/man1/$argv[1].1" >$tmpdir/$argv.1
|
||||
set argv $tmpdir/$argv.1
|
||||
set -l basename $argv[1].1
|
||||
function __fish_man -V basename -a man1
|
||||
command man $man1/$basename
|
||||
end
|
||||
__fish_data_with_directory man/man1 \
|
||||
(string escape --style=regex -- $basename) __fish_man
|
||||
__fish_with_status functions --erase __fish_man
|
||||
else
|
||||
command man $argv
|
||||
end
|
||||
|
||||
command man $argv
|
||||
set -l saved_status $status
|
||||
|
||||
if set -q tmpdir[1]
|
||||
command rm -r $tmpdir
|
||||
end
|
||||
|
||||
return $saved_status
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user