diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-10-20 23:21:57 +0200 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-02-26 12:14:55 +0100 |
commit | c1b384e5d3f2f46e7d7a1b41e31c7aadc1d9ce28 (patch) | |
tree | d8a503f47681505cef7cbbdbdc4f3b0541d768f8 /share/config.fish | |
parent | 8b67a1b26f2525f7de1e2a64dee6ab48b72b0e33 (diff) |
Add functions and configuration snippets hierarchy
This allows "vendors" (i.e. third-party upstreams interested in
supporting fish) to add auto-loaded functions and eager-loaded
configuration "snippets", while still allowing both the user and the administrator to
fully override all of that.
This has been inspired by systemd's configuration hierarchy, and implements a similar scheme
whereby files with the same name in higher-ranking directories override files in lower-ranking ones.
Fixes #1956
Diffstat (limited to 'share/config.fish')
-rw-r--r-- | share/config.fish | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/share/config.fish b/share/config.fish index b1d404ee..40000740 100644 --- a/share/config.fish +++ b/share/config.fish @@ -49,7 +49,7 @@ end # 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 $__fish_datadir/functions + set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__fish_datadir/vendor_functions.d $__fish_datadir/functions end if not contains $__fish_datadir/functions $fish_function_path @@ -151,3 +151,15 @@ function . --description 'Evaluate contents of file (deprecated, see "source")' source $argv end end + +# As last part of initialization, source the conf directories +# Implement precedence (User > Admin > Vendors > Fish) by basically doing "basename" +set -l sourcelist +for file in $configdir/fish/conf.d/* $__fish_sysconfdir/conf.d/* $__fish_datadir/vendor_conf.d/* + 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 |