aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.in17
-rw-r--r--configure.ac26
-rw-r--r--doc_src/index.hdr.in52
-rw-r--r--fish.pc.in6
-rw-r--r--fish.xcodeproj/project.pbxproj28
-rw-r--r--share/__fish_build_paths.fish.in8
-rw-r--r--share/config.fish17
8 files changed, 106 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore
index 704ec8d0..e0713b06 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ fish_tests
fish.pc
seq
set_color
+share/__fish_build_paths.fish
share/man/
toc.txt
user_doc/
diff --git a/Makefile.in b/Makefile.in
index ede69b0f..5526fa6d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -53,6 +53,9 @@ mandir = @mandir@
sysconfdir = @sysconfdir@
docdir = @docdir@
localedir = @localedir@
+extra_completionsdir = @extra_completionsdir@
+extra_functionsdir = @extra_functionsdir@
+extra_snippetsdir = @extra_snippetsdir@
#
# pcre2
@@ -224,7 +227,7 @@ endif
# Make everything needed for installing fish
#
-all: $(PROGRAMS) $(user_doc) $(share_man) $(TRANSLATIONS) fish.pc
+all: $(PROGRAMS) $(user_doc) $(share_man) $(TRANSLATIONS) fish.pc share/__fish_build_paths.fish
@echo fish has now been built.
@echo Use \'$(MAKE) install\' to install fish.
.PHONY: all
@@ -467,6 +470,9 @@ doc.h: $(HDR_FILES)
-e "s,@sysconfdir\@,$(sysconfdir),g" \
-e "s,@datadir\@,$(datadir),g" \
-e "s,@docdir\@,$(docdir),g" \
+ -e "s,@extra_completionsdir\@,$(extra_completionsdir),g" \
+ -e "s,@extra_functionsdir\@,$(extra_functionsdir),g" \
+ -e "s,@extra_snippetsdir\@,$(extra_snippetsdir),g" \
-e "s|@configure_input\@|$@, generated from $@.in by the Makefile. DO NOT MANUALLY EDIT THIS FILE!|g" \
-e "s,@prefix\@,$(prefix),g" \
-e "s,@fish_build_version\@,$(FISH_BUILD_VERSION),g" \
@@ -657,9 +663,9 @@ install-force: all install-translations
$(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)$(extra_completionsdir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(extra_functionsdir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(extra_snippetsdir)
$(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
@@ -669,6 +675,7 @@ install-force: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
+ $(INSTALL) -m 644 share/__fish_build_paths.fish $(DESTDIR)$(datadir)/fish/
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/pkgconfig
$(INSTALL) -m 644 fish.pc $(DESTDIR)$(datadir)/pkgconfig
for i in $(COMPLETIONS_DIR_FILES:%='%'); do \
@@ -899,7 +906,7 @@ clean:
rm -f doc_src/index.hdr doc_src/commands.hdr
rm -f lexicon_filter lexicon.txt lexicon.log
rm -f compile_commands.json xcodebuild.log
- rm -f FISH-BUILD-VERSION-FILE fish.pc
+ rm -f FISH-BUILD-VERSION-FILE fish.pc share/__fish_build_paths.fish
if test "$(HAVE_DOXYGEN)" = 1; then \
rm -rf doc user_doc share/man; \
fi
diff --git a/configure.ac b/configure.ac
index af4fc5af..f31825ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -845,7 +845,7 @@ You may need to install the PCRE2 development library for your system.])
fi
fi
-# Re-test as value may have changed
+# Re-test as value may have changed.
if test "x$included_pcre2" = "xyes"; then
# Build configure/Makefile for pcre2
AC_MSG_NOTICE([using included PCRE2 library])
@@ -862,7 +862,29 @@ if test "x$included_pcre2" = "xyes"; then
LIBS="$LIBS $PCRE2_LIBS"
fi
-# Tell the world what we know
+# Allow configurable extra directories.
+AC_SUBST(extra_completionsdir)
+AC_ARG_WITH([extra-completionsdir],
+ AS_HELP_STRING([--with-extra-completionsdir=DIR],
+ [path for extra completions]),
+ [extra_completionsdir=$withval],
+ [extra_completionsdir='${datadir}/fish/vendor_completions.d'])
+
+AC_SUBST(extra_functionsdir)
+AC_ARG_WITH([extra_functionsdir],
+ AS_HELP_STRING([--with-extra-functionsdir=DIR],
+ [path for extra functions]),
+ [extra_functionsdir=$withval],
+ [extra_functionsdir='${datadir}/fish/vendor_functions.d'])
+
+AC_SUBST(extra_snippetsdir)
+AC_ARG_WITH([extra-snippetsdir],
+ AS_HELP_STRING([--with-extra-snippetsdir=DIR],
+ [path for extra snippets]),
+ [extra_snippetsdir=$withval],
+ [extra_snippetsdir='${datadir}/fish/vendor_conf.d'])
+
+# Tell the world what we know.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in
index a42fb649..b75ee5e1 100644
--- a/doc_src/index.hdr.in
+++ b/doc_src/index.hdr.in
@@ -247,11 +247,21 @@ Functions can be defined on the commandline or in a configuration file, but they
Fish automatically searches through any directories in the array variable `$fish_function_path`, and any functions defined are automatically loaded when needed. A function definition file must have a filename consisting of the name of the function plus the suffix '`.fish`'.
-The default value for `$fish_function_path` is `~/.config/fish/functions` `/etc/fish/functions` `/usr/share/fish/functions`. The exact path to the last two of these may be slightly different depending on what install path prefix was chosen at configuration time. The rationale behind having three different directories is that the first one is for user specific functions, the second one is for system-wide additional functions and the last one is for default fish functions. The path list is searched in order, meaning that by default, the system administrator can override default fish functions, and the user can override functions defined by the system administrator.
+By default, Fish searches the following for functions, using the first available file that it finds:
+- A directory for end-users to keep their own functions, usually `~/.config/fish/functions` (controlled by the `XDG_CONFIG_HOME` environment variable).
+- A directory for systems administrators to install functions for all users on the system, usually `/etc/fish/functions`.
+- A directory for third-party software vendors to ship their own functions for their software, usually `/usr/share/fish/vendor_functions.d`.
+- The functions shipped with fish, usually installed in `/usr/share/fish/functions`.
+
+These paths are controlled by parameters set at build, install, or run time, and may vary from the defaults listed above.
+
+This wide search may be confusing. If you are unsure, your functions probably belong in `~/.config/fish/functions`.
It is very important that function definition files only contain the definition for the specified function and nothing else. Otherwise, it is possible that autoloading a function files requires that the function already be loaded, which creates a circular dependency.
-Autoloading also won't work for <a href=#event>event handlers</a>, since fish cannot know that a function is supposed to be executed when an event occurs when it hasn't yet loaded the function. See there for details.
+Autoloading also won't work for <a href=#event>event handlers</a>, since fish cannot know that a function is supposed to be executed when an event occurs when it hasn't yet loaded the function. See the <a href=#event>event handlers</a> section for more information.
+
+If you are developing another program, you may wish to install functions which are available for all users of the fish shell on a system. They can be installed to the "vendor" functions directory. As this path may vary from system to system, the `pkgconfig` framework should be used to discover this path with the output of `pkg-config --variable functionsdir fish`.
\subsubsection syntax-conditional Conditional execution of code and flow control
@@ -381,9 +391,20 @@ Functions beginning with the string `__fish_print_` print a newline separated li
Completions can be defined on the commandline or in a configuration file, but they can also be automatically loaded. Fish automatically searches through any directories in the array variable `$fish_complete_path`, and any completions defined are automatically loaded when needed. A completion file must have a filename consisting of the name of the command to complete and the suffix '`.fish`'.
-The default value for `$fish_complete_path` is `~/.config/fish/completions` `/etc/fish/completions` `/usr/share/fish/vendor_completions.d` `/usr/share/fish/completions` `~/.local/share/generated_completions`. (Some paths may be slightly different depending on where fish is installed). If a suitable file is found in one of these directories, it will be automatically loaded and the search will be stopped. The large number of directories searched may be confusing. It is to allow, respectively, user-specific completions, system-wide completions, completions installed by other packages, default completions that ship with fish, and finally, completions generated from manual pages. If you are unsure, put your completions in `~/.config/fish/completions`.
+By default, Fish searches the following for completions, using the first available file that it finds:
+- A directory for end-users to keep their own completions, usually `~/.config/fish/completions` (controlled by the `XDG_CONFIG_HOME` environment variable);
+- A directory for systems administrators to install completions for all users on the system, usually `/etc/fish/completions`;
+- A directory for third-party software vendors to ship their own completions for their software, usually `/usr/share/fish/vendor_completions.d`;
+- The completions shipped with fish, usually installed in `/usr/share/fish/completions`; and
+- Completions automatically generated from the operating system's manual, usually stored in `~/.local/share/generated_completions`.
+
+These paths are controlled by parameters set at build, install, or run time, and may vary from the defaults listed above.
+
+This wide search may be confusing. If you are unsure, your completions probably belong in `~/.config/fish/completions`.
+
+If you have written new completions for a common Unix command, please consider sharing your work by submitting it via the instructions in <a href="#more-help">Further help and development</a>.
-If you have written new completions for a common Unix command, please consider sharing your work by submitting it via the instructions in <a href="#more-help">Further help and development</a>. If you are developing another program and would like to ship completions with your program, install them to `/usr/share/fish/vendor_completions.d` or similar directory. Systems using the `pkgconfig` framework can discover this path from the output of `pkg-config --variable completionsdir fish`.
+If you are developing another program and would like to ship completions with your program, install them to the "vendor" completions directory. As this path may vary from system to system, the `pkgconfig` framework should be used to discover this path with the output of `pkg-config --variable completionsdir fish`.
\section expand Parameter expansion (Globbing)
@@ -1085,9 +1106,27 @@ Note that functions cannot be started in the background. Functions that are stop
\section initialization Initialization files
-On startup, `fish` evaluates the files `/usr/share/fish/config.fish` (Or `/usr/local/fish...` if you installed fish in `/usr/local`), `/etc/fish/config.fish` (Or `~/etc/fish/...` if you installed fish in your home directory) and `~/.config/fish/config.fish` (Or any other directory specified by the `$XDG_CONFIG_HOME` variable), in that order.
+On startup, Fish evaluates a number of configuration files, which can be used to control the behavior of the shell.
+
+Configuration files are evaluated in the following order:
+- Configuration shipped with fish, which should not be edited, 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 - usually `/etc/fish/config.fish`;
+- "Unit" configuration files ending in `.fish`, in the directories:
+ - `~/.config/fish/conf.d/`
+ - `/etc/fish/conf.d`
+ - `/usr/share/fish/vendor_conf.d`
+
+ If there are multiple files with the same name in these directories, only the first will be executed.
+
+- User initialization, usually in `~/.config/fish/config.fish` (controlled by the `XDG_CONFIG_HOME` environment variable).
+
+These paths are controlled by parameters set at build, install, or run time, and may vary from the defaults listed above.
+
+This wide search may be confusing. If you are unsure, use `~/.config/fish/config.fish`.
+
+These files are all executed on the startup of every shell. If you want to run a command only on starting an interactive shell, use the exit status of the command `status --is-interactive` to determine if the shell is interactive. If you want to run a command only when using a login shell, use `status --is-login` instead. This will speed up the starting of non-interactive or non-login shells.
-The first file should not be directly edited, the second one is meant for systemwide configuration and the last one is meant for user configuration. If you want to run a command only on starting an interactive shell, use the exit status of the command `status --is-interactive` to determine if the shell is interactive. If you want to run a command only when using a login shell, use `status --is-login` instead.
+If you are developing another program, you may wish to install configuration which is run for all users of the fish shell on a system. This is discouraged; if not carefully written, they may have side-effects or slow the startup of the shell. Additionally, users of other shells will not benefit from the Fish-specific configuration. However, if they are absolutely required, you may install them to the "vendor" configuration directory. As this path may vary from system to system, the `pkgconfig` framework should be used to discover this path with the output of `pkg-config --variable confdir fish`.
Examples:
@@ -1107,7 +1146,6 @@ 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 ending in ".fish" 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 c8fabd7e..d110a2fb 100644
--- a/fish.pc.in
+++ b/fish.pc.in
@@ -1,8 +1,8 @@
prefix=@prefix@
datadir=@datadir@
-completionsdir=${datadir}/fish/vendor_completions.d
-functionsdir=${datadir}/fish/vendor_functions.d
-confdir=${datadir}/fish/vendor_conf.d
+completionsdir=@extra_completionsdir@
+functionsdir=@extra_functionsdir@
+confdir=@extra_snippetsdir@
Name: fish
Description: fish, the friendly interactive shell
diff --git a/fish.xcodeproj/project.pbxproj b/fish.xcodeproj/project.pbxproj
index 0f7e5efc..6d2ca902 100644
--- a/fish.xcodeproj/project.pbxproj
+++ b/fish.xcodeproj/project.pbxproj
@@ -24,7 +24,6 @@
buildPhases = (
D07D266915E33B86009E43F6 /* CopyFiles */,
D07D266B15E33B86009E43F6 /* Copy Files */,
- D01A25E11AF58D8C002F9E92 /* ShellScript */,
D01A2CA716965ADD00767098 /* CopyFiles */,
);
dependencies = (
@@ -55,7 +54,6 @@
D0F019FC15A977B40034B3B1 /* CopyFiles */,
D033780F15DC6D2A00A634BA /* CopyFiles */,
D01A2C9B16964C8200767098 /* Copy Files */,
- D01A25E01AF58CD0002F9E92 /* ShellScript */,
);
dependencies = (
D0F01A1315AA36280034B3B1 /* PBXTargetDependency */,
@@ -1048,32 +1046,6 @@
shellPath = /bin/sh;
shellScript = ./build_tools/xcode_version_gen.sh;
};
- D01A25E01AF58CD0002F9E92 /* ShellScript */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "mkdir -p -m 755 \"${TARGET_BUILD_DIR}/base/share/fish/vendor_completions.d\"";
- };
- D01A25E11AF58D8C002F9E92 /* ShellScript */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 8;
- files = (
- );
- inputPaths = (
- );
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 1;
- shellPath = /bin/sh;
- shellScript = "mkdir -p -m 755 \"${INSTALL_ROOT}/${INSTALL_PATH}/share/fish/vendor_completions.d\"";
- };
D0A564EB168CFDDE00AF6161 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
diff --git a/share/__fish_build_paths.fish.in b/share/__fish_build_paths.fish.in
new file mode 100644
index 00000000..4b923d7e
--- /dev/null
+++ b/share/__fish_build_paths.fish.in
@@ -0,0 +1,8 @@
+# @configure_input@
+# This function is generated by the autotools build to "compile in"
+# the local "vendor" completions, functions and configuration snippets.
+# It is sourced by share/config.fish, if it exists.
+
+set __extra_completionsdir @extra_completionsdir@
+set __extra_functionsdir @extra_functionsdir@
+set __extra_snippetsdir @extra_snippetsdir@
diff --git a/share/config.fish b/share/config.fish
index fe45f70d..3f798652 100644
--- a/share/config.fish
+++ b/share/config.fish
@@ -45,11 +45,20 @@ end
# __fish_datadir, __fish_sysconfdir, __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
+# third-party packages to ship completions &c.
+set -l __extra_completionsdir
+set -l __extra_functionsdir
+set -l __extra_snippetsdir
+if test -f $__fish_datadir/__fish_build_paths.fish
+ source $__fish_datadir/__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 $__fish_datadir/vendor_functions.d $__fish_datadir/functions
+ set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__extra_functionsdir $__fish_datadir/functions
end
if not contains $__fish_datadir/functions $fish_function_path
@@ -57,7 +66,7 @@ if not contains $__fish_datadir/functions $fish_function_path
end
if not set -q fish_complete_path
- set fish_complete_path $configdir/fish/completions $__fish_sysconfdir/completions $__fish_datadir/vendor_completions.d $__fish_datadir/completions $userdatadir/fish/generated_completions
+ set fish_complete_path $configdir/fish/completions $__fish_sysconfdir/completions $__extra_completionsdir $__fish_datadir/completions $userdatadir/fish/generated_completions
end
if not contains $__fish_datadir/completions $fish_complete_path
@@ -155,9 +164,9 @@ function . --description 'Evaluate contents of file (deprecated, see "source")'
end
# As last part of initialization, source the conf directories
-# Implement precedence (User > Admin > Vendors > Fish) by basically doing "basename"
+# 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 $__fish_datadir/vendor_conf.d/*.fish
+for file in $configdir/fish/conf.d/*.fish $__fish_sysconfdir/conf.d/*.fish $__extra_snippetsdir/*.fish
set -l basename (string replace -r '^.*/' '' -- $file)
contains -- $basename $sourcelist; and continue
set sourcelist $sourcelist $basename