I have recently moved to fish from bash. I'm immediately in love with the out-of-the-box functionality, but I'm a little bit at a loss when it comes to configuring the shell.
I've read through the documentation, particularly the section about initialization, and it states:
On startup, Fish evaluates a number of configuration files...
- Configuration snippets in files ending in .fish, in the directories:
$__fish_config_dir/conf.d
(by default,~/.config/fish/conf.d/
)- ...
- User initialization, usually in
~/.config/fish/config.fish
...
So far, this is clear to understand. Coming from bash, I took my .bash_globals
and .bash_aliases
files, rewrote them a little bit according to fish's syntax, placed them into the ~/.config/fish/conf.d/
and they are loaded as expected.
However, when I looked over the contents of the config.fish
file, I couldn't figure out anything that would need to be put there. To my understanding, fish is designed to work already out of the box, so the usual bash config like setting HISTCONTROL
isn't necessary. Nor are the conf.d/
files called from some main script (like the .bash_aliases
, etc., would be in .bashrc
) - they're loaded automatically.
Is there some particular use case where config.fish
is preferred - or even required - over conf.d/
files? So far, I would say individual files are cleaner to read, maintain and move between hosts. Is there some convention that's recommended to follow? Was there a specific motivation behind allowing so many levels of config, aside from giving users more freedom?
.bash_globals
nor.bash_aliases
are standard bash features. I know Ubuntu creates this.bash_aliases
file and sources it from.bashrc
, so maybe some other Linux flavors also do it, but it has nothing to do withbash
. I don't even know what.bash_globals
is, probably something specific to whatever system you are using. Also, there is no need to setHISTCONTROL
or anything else inbash
. If you are happy with the defaults, you can leave them. It works perfectly well out of the box.config.fish
orconf.d/
files, you have the option of wrapping them in anif status is-interactive
orif status is-login
if there's something you would prefer to run only in those types of shells.config.fish
or theconf.d/
files?fish
does behave differently in at least one way frombash
as described in that answer -- It does execute the startup files when executed with-c command
. That's why I do like to wrap my startup files inif status is-interactive
orif status is-login
where appropriate. But it doesn't change the (lack of) need for a shebang in those files.