diff --git a/Makefile.in b/Makefile.in index 88155b2d5..056a3d814 100644 --- a/Makefile.in +++ b/Makefile.in @@ -660,9 +660,12 @@ install-force: all install-translations true ;\ done; $(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish + $(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish/conf.d $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_completions.d + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_functions.d + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_conf.d $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man/man1 $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index 9531876b5..a0f7ec0a2 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -1088,6 +1088,7 @@ function on_exit --on-process %self end \endfish +Right after reading /usr/share/fish/config.fish and before reading /etc/fish/config.fish, fish will also read files in ~/.config/fish/conf.d/, /etc/fish/conf.d and /usr/share/fish/vendor_conf.d (the exact values depend on $XDG_CONFIG_HOME, $__fish_sysconfdir and $__fish_datadir). If there are files with the same name in two or all of these, fish will only attempt to read the first (skipping all files with that name if it is unreadable). ~/.config takes precedence over /etc/ which takes precedence over /usr. The path to the latter can also be gotten via `pkg-config` as "confdir", and is meant for third-party applications to integrate with fish. \section other Other features diff --git a/fish.pc.in b/fish.pc.in index cae82246b..c8fabd7e8 100644 --- a/fish.pc.in +++ b/fish.pc.in @@ -1,6 +1,8 @@ prefix=@prefix@ datadir=@datadir@ completionsdir=${datadir}/fish/vendor_completions.d +functionsdir=${datadir}/fish/vendor_functions.d +confdir=${datadir}/fish/vendor_conf.d Name: fish Description: fish, the friendly interactive shell diff --git a/share/config.fish b/share/config.fish index b1d404eec..400007409 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