Read conf.d snippets as last part of share/config.fish

This allows snippets to use everything that is defined in config.fish,
which is our _base_ initialization.

Among other things, it enables snippets to use $PATH as it will appear
in the user's config.fish, or even to change $PATH.

Also, this is how it was in 2.7.1 and before (with the small change
that abbrs were upgraded after).
This commit is contained in:
Fabian Homborg 2018-06-12 22:28:26 +02:00
parent 1270bb265f
commit 64ff2f7895

View file

@ -184,20 +184,6 @@ function . --description 'Evaluate contents of file (deprecated, see "source")'
end end
end end
# 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_sysconf_dir/conf.d/*.fish $__extra_confdir/*.fish
set -l basename (string replace -r '^.*/' '' -- $file)
contains -- $basename $sourcelist
and continue
set sourcelist $sourcelist $basename
# Also skip non-files or unreadable files.
# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd).
[ -f $file -a -r $file ]
and source $file
end
# Upgrade pre-existing abbreviations from the old "key=value" to the new "key value" syntax. # Upgrade pre-existing abbreviations from the old "key=value" to the new "key value" syntax.
# This needs to be in share/config.fish because __fish_config_interactive is called after sourcing # This needs to be in share/config.fish because __fish_config_interactive is called after sourcing
# config.fish, which might contain abbr calls. # config.fish, which might contain abbr calls.
@ -305,3 +291,16 @@ function disown --wraps disown
builtin disown (__fish_expand_pid_args $argv) builtin disown (__fish_expand_pid_args $argv)
end end
# 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_sysconf_dir/conf.d/*.fish $__extra_confdir/*.fish
set -l basename (string replace -r '^.*/' '' -- $file)
contains -- $basename $sourcelist
and continue
set sourcelist $sourcelist $basename
# Also skip non-files or unreadable files.
# This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd).
[ -f $file -a -r $file ]
and source $file
end