fish -l or fish --login to run as login shell
if status is-login
echo 'login shell'
else
echo 'non-login shell'
end
fish -i or fish --interactive to run as interactive shell
if status is-interactive
echo 'interactive shell'
else
echo 'non-interactive shell'
end
Fish uses a lot of directory paths to store its configs:
| Config |
Variable |
Path |
| user |
$__fish_config_dir |
$XDG_CONFIG_HOME/fish => ~/.config/fish |
| system-wide |
$__fish_sysconf_dir |
/etc/fish |
| software |
$__fish_user_data_dir |
$XDG_DATA_HOME/fish => ~/.local/share/fish |
| vendor |
$__fish_data_dir |
/usr/share/fish (varies) |
If $XDG_DATA_DIRS is set, loop through it (path variable), otherwise $__fish_data_dir is used:
- each
{path}/fish/vendor_conf.d is appended to $__fish_vendor_confdirs
- each
{path}/fish/vendor_functions.d is appended to $__fish_vendor_functionsdirs
- each
{path}/fish/vendor_completions.d is appended to $__fish_vendor_completionsdirs
Note: updating $XDG_DATA_DIRS won't update *dirs variables retrospectively.
--no-config/-N skips sourcing all config files.
/usr/share/fish/config.fish sources next files, if these any duplicates basenames (/some/path/dir.fish -> dir.fish) only first will be sourced:
$__fish_config_dir/conf.d/*.fish
$__fish_sysconf_dir/conf.d/*.fish
- loop through
$__fish_vendor_confdirs paths for *.fish
$__fish_sysconf_dir/config.fish
$__fish_config_dir/config.fish
In fish, functions and completions are lazily loaded, means they don't get sourced until they're typed or ran.
For example if we want to run custom function hello it needs to be stored in (ex. $__fish_config_dir/functions/hello.fish). There are two side-effects:
- If there are two identically named function files only first one will be sourced.
- If there additional commands in function file or even different function they will be called once
New paths can be added by appending to fish_function_path and fish_complete_path variables with no reload required, if there multiple identical functions/completions in the path first found takes precedence.
Lookup paths for functions:
$__fish_config_dir/functions
$__fish_sysconf_dir/functions
$__fish_vendor_functionsdirs
$__fish_data_dir/functions
Lookup paths for completions:
$__fish_config_dir/completions
$__fish_sysconf_dir/completions
$__fish_vendor_completionsdirs
$__fish_data_dir/completions
$__fish_user_data_dir/generated_completions - generated by fish_update_completions command
Reference