mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
parent
b42b562d06
commit
c51abd04ff
|
@ -1235,12 +1235,12 @@ Note that functions cannot be started in the background. Functions that are stop
|
|||
On startup, Fish evaluates a number of configuration files, which can be used to control the behavior of the shell. The location of these configuration variables is controlled by a number of environment variables, and their default or usual location is given below.
|
||||
|
||||
Configuration files are evaluated in the following order:
|
||||
- Configuration shipped with fish, which should not be edited, in `$__fish_datadir/config.fish` (usually `/usr/share/fish/config.fish`).
|
||||
- System-wide configuration files, where administrators can include initialization that should be run for all users on the system - similar to `/etc/profile` for POSIX-style shells - in `$__fish_sysconfdir` (usually `/etc/fish/config.fish`);
|
||||
- Configuration shipped with fish, which should not be edited, in `$__fish_data_dir/config.fish` (usually `/usr/share/fish/config.fish`).
|
||||
- System-wide configuration files, where administrators can include initialization that should be run for all users on the system - similar to `/etc/profile` for POSIX-style shells - in `$__fish_sysconf_dir` (usually `/etc/fish/config.fish`);
|
||||
- Configuration snippets in files ending in `.fish`, in the directories:
|
||||
- `$XDG_CONFIG_HOME/fish/conf.d` (by default, `~/.config/fish/conf.d/`)
|
||||
- `$__fish_sysconfdir/conf.d` (by default, `/etc/fish/conf.d`)
|
||||
- `/usr/share/fish/vendor_conf.d` (set at compile time; by default, `$__fish_datadir/conf.d`)
|
||||
- `$__fish_sysconf_dir/conf.d` (by default, `/etc/fish/conf.d`)
|
||||
- `/usr/share/fish/vendor_conf.d` (set at compile time; by default, `$__fish_data_dir/conf.d`)
|
||||
|
||||
If there are multiple files with the same name in these directories, only the first will be executed.
|
||||
They are executed in order of their filename, sorted (like globs) in a natural order (i.e. "01" sorts before "2").
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if test -d "$__fish_datadir/man/man1/"
|
||||
if test -d "$__fish_data_dir/man/man1/"
|
||||
complete -c help -x -a '(__fish_print_commands)' -d 'Help for this command'
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ if status --is-interactive
|
|||
# These "XXX nostring" hacks were added for 2.3.1
|
||||
set_color --bold
|
||||
echo "You appear to be trying to launch an old fish binary with newer scripts "
|
||||
echo "installed into" (set_color --underline)"$__fish_datadir"
|
||||
echo "installed into" (set_color --underline)"$__fish_data_dir"
|
||||
set_color normal
|
||||
echo -e "\nThis is an unsupported configuration.\n"
|
||||
set_color yellow
|
||||
|
@ -74,7 +74,7 @@ if set -q XDG_DATA_HOME
|
|||
set userdatadir $XDG_DATA_HOME
|
||||
end
|
||||
|
||||
# __fish_datadir, __fish_sysconfdir, __fish_help_dir, __fish_bin_dir
|
||||
# __fish_data_dir, __fish_sysconf_dir, __fish_help_dir, __fish_bin_dir
|
||||
# are expected to have been set up by read_init from fish.cpp
|
||||
|
||||
# Grab extra directories (as specified by the build process, usually for
|
||||
|
@ -82,27 +82,27 @@ end
|
|||
set -l __extra_completionsdir
|
||||
set -l __extra_functionsdir
|
||||
set -l __extra_confdir
|
||||
if test -f $__fish_datadir/__fish_build_paths.fish
|
||||
source $__fish_datadir/__fish_build_paths.fish
|
||||
if test -f $__fish_data_dir/__fish_build_paths.fish
|
||||
source $__fish_data_dir/__fish_build_paths.fish
|
||||
end
|
||||
|
||||
# Set up function and completion paths. Make sure that the fish
|
||||
# default functions/completions are included in the respective path.
|
||||
|
||||
if not set -q fish_function_path
|
||||
set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__extra_functionsdir $__fish_datadir/functions
|
||||
set fish_function_path $configdir/fish/functions $__fish_sysconf_dir/functions $__extra_functionsdir $__fish_data_dir/functions
|
||||
end
|
||||
|
||||
if not contains -- $__fish_datadir/functions $fish_function_path
|
||||
set fish_function_path $fish_function_path $__fish_datadir/functions
|
||||
if not contains -- $__fish_data_dir/functions $fish_function_path
|
||||
set fish_function_path $fish_function_path $__fish_data_dir/functions
|
||||
end
|
||||
|
||||
if not set -q fish_complete_path
|
||||
set fish_complete_path $configdir/fish/completions $__fish_sysconfdir/completions $__extra_completionsdir $__fish_datadir/completions $userdatadir/fish/generated_completions
|
||||
set fish_complete_path $configdir/fish/completions $__fish_sysconf_dir/completions $__extra_completionsdir $__fish_data_dir/completions $userdatadir/fish/generated_completions
|
||||
end
|
||||
|
||||
if not contains -- $__fish_datadir/completions $fish_complete_path
|
||||
set fish_complete_path $fish_complete_path $__fish_datadir/completions
|
||||
if not contains -- $__fish_data_dir/completions $fish_complete_path
|
||||
set fish_complete_path $fish_complete_path $__fish_data_dir/completions
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -222,7 +222,7 @@ __fish_set_locale
|
|||
# As last part of initialization, source the conf directories.
|
||||
# Implement precedence (User > Admin > Extra (e.g. vendors) > Fish) by basically doing "basename".
|
||||
set -l sourcelist
|
||||
for file in $configdir/fish/conf.d/*.fish $__fish_sysconfdir/conf.d/*.fish $__extra_confdir/*.fish
|
||||
for file in $configdir/fish/conf.d/*.fish $__fish_sysconf_dir/conf.d/*.fish $__extra_confdir/*.fish
|
||||
set -l basename (string replace -r '^.*/' '' -- $file)
|
||||
contains -- $basename $sourcelist
|
||||
and continue
|
||||
|
|
|
@ -70,7 +70,7 @@ function __fish_complete_man
|
|||
|
||||
# Fish commands are not given by apropos
|
||||
if not set -ql exclude_fish_commands
|
||||
set -l files $__fish_datadir/man/man1/*.1
|
||||
set -l files $__fish_data_dir/man/man1/*.1
|
||||
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files
|
||||
end
|
||||
else
|
||||
|
|
|
@ -131,7 +131,7 @@ function __fish_config_interactive -d "Initializations that should be performed
|
|||
# We don't want to call `fish -c` since that is unnecessary and sources config.fish again.
|
||||
# Hence we'll call python directly.
|
||||
# c_m_p.py should work with any python version.
|
||||
set -l update_args -B $__fish_datadir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions'
|
||||
set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions'
|
||||
if command -qs python3
|
||||
python3 $update_args >/dev/null ^/dev/null &
|
||||
else if command -qs python2
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function __fish_print_commands --description "Print a list of documented fish commands"
|
||||
if test -d $__fish_datadir/man/man1/
|
||||
for file in $__fish_datadir/man/man1/**.1*
|
||||
if test -d $__fish_data_dir/man/man1/
|
||||
for file in $__fish_data_dir/man/man1/**.1*
|
||||
string replace -r '.*/' '' -- $file | string replace -r '.1(.gz)?$' ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ function __fish_print_help --description "Print help message for the specified f
|
|||
end
|
||||
|
||||
# Do nothing if the file does not exist
|
||||
if not test -e "$__fish_datadir/man/man1/$item.1" -o -e "$__fish_datadir/man/man1/$item.1.gz"
|
||||
if not test -e "$__fish_data_dir/man/man1/$item.1" -o -e "$__fish_data_dir/man/man1/$item.1.gz"
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -37,15 +37,15 @@ 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 rLL -rLL=$cols[1]n
|
||||
end
|
||||
set -lx GROFF_TMAC_PATH $__fish_datadir/groff
|
||||
set -lx GROFF_TMAC_PATH $__fish_data_dir/groff
|
||||
set -l mfish
|
||||
if test -e $GROFF_TMAC_PATH/fish.tmac
|
||||
set mfish -mfish
|
||||
end
|
||||
if test -e "$__fish_datadir/man/man1/$item.1"
|
||||
set help (nroff -c -man $mfish -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 -c -man $mfish -t $rLL ^/dev/null)
|
||||
if test -e "$__fish_data_dir/man/man1/$item.1"
|
||||
set help (nroff -c -man $mfish -t $rLL "$__fish_data_dir/man/man1/$item.1" ^/dev/null)
|
||||
else if test -e "$__fish_data_dir/man/man1/$item.1.gz"
|
||||
set help (gunzip -c "$__fish_data_dir/man/man1/$item.1.gz" ^/dev/null | nroff -c -man $mfish -t $rLL ^/dev/null)
|
||||
end
|
||||
|
||||
# The original implementation trimmed off the top 5 lines and bottom 3 lines
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
function fish_config --description "Launch fish's web based configuration"
|
||||
set -lx __fish_bin_dir $__fish_bin_dir
|
||||
if command -sq python3
|
||||
python3 "$__fish_datadir/tools/web_config/webconfig.py" $argv
|
||||
python3 "$__fish_data_dir/tools/web_config/webconfig.py" $argv
|
||||
else if command -sq python2
|
||||
python2 "$__fish_datadir/tools/web_config/webconfig.py" $argv
|
||||
python2 "$__fish_data_dir/tools/web_config/webconfig.py" $argv
|
||||
else if command -sq python
|
||||
python "$__fish_datadir/tools/web_config/webconfig.py" $argv
|
||||
python "$__fish_data_dir/tools/web_config/webconfig.py" $argv
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ function fish_update_completions --description "Update man-page based completion
|
|||
end
|
||||
|
||||
# Clean up old paths
|
||||
set -l update_args -B $__fish_datadir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions' --progress
|
||||
set -l update_args -B $__fish_data_dir/tools/create_manpage_completions.py --manpath --cleanup-in '~/.config/fish/completions' --cleanup-in '~/.config/fish/generated_completions' --progress
|
||||
if command -qs python3
|
||||
python3 $update_args
|
||||
else if command -qs python2
|
||||
|
|
|
@ -110,7 +110,7 @@ function help --description 'Show help for the fish shell'
|
|||
# Prefer to use fish's man pages, to avoid
|
||||
# the annoying useless "builtin" man page bash
|
||||
# installs on OS X
|
||||
set -l man_arg "$__fish_datadir/man/man1/$fish_help_item.1"
|
||||
set -l man_arg "$__fish_data_dir/man/man1/$fish_help_item.1"
|
||||
if test -f "$man_arg"
|
||||
man $man_arg
|
||||
return
|
||||
|
@ -164,7 +164,7 @@ function help --description 'Show help for the fish shell'
|
|||
# by using a custom style sheet. See https://github.com/fish-shell/fish-shell/issues/4170
|
||||
set -l local_file 0
|
||||
if eval $fish_browser --version 2>/dev/null | string match -qr Lynx
|
||||
set fish_browser $fish_browser -lss={$__fish_datadir}/lynx.lss
|
||||
set fish_browser $fish_browser -lss={$__fish_data_dir}/lynx.lss
|
||||
end
|
||||
eval $fish_browser $page_url
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ function man --description "Format and display the on-line manual pages"
|
|||
# Notice local exported copy of the variable.
|
||||
set -lx MANPATH $manpath
|
||||
|
||||
set -l fish_manpath (dirname $__fish_datadir)/fish/man
|
||||
set -l fish_manpath (dirname $__fish_data_dir)/fish/man
|
||||
if test -d "$fish_manpath" -a -n "$MANPATH"
|
||||
set MANPATH $fish_manpath:$MANPATH
|
||||
# Invoke man with this manpath, and we're done.
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
#define DEFAULT_TERM2 "dumb"
|
||||
|
||||
/// Some configuration path environment variables.
|
||||
#define FISH_DATADIR_VAR L"__fish_datadir"
|
||||
#define FISH_SYSCONFDIR_VAR L"__fish_sysconfdir"
|
||||
#define FISH_DATADIR_VAR L"__fish_data_dir"
|
||||
#define FISH_SYSCONFDIR_VAR L"__fish_sysconf_dir"
|
||||
#define FISH_HELPDIR_VAR L"__fish_help_dir"
|
||||
#define FISH_BIN_DIR L"__fish_bin_dir"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user