This will be my documentation of an attempt to determine the differences between and what each of
.profile files are used for. It could get messy, but there are definite differences and likely an optimal setup. Oh, and I'll put My Config in here as well.
.profilefile in favor of the more "*nix standard"
.bash_profileloads other dot files that are used for specific purposes
.bash_profileis used primarily for command-oriented stuff like tab completion
Whoa. This shit is confusing.
It appears the difference is when a file is loaded, and what for. The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine) and others that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system).
And then there's the fact that
bash complicates this in that
.bashrc is only read by a shell that's both interactive and non-login, so anecdotally it sounds like many (most?) people end up telling their
.bash_profile to also read
.bashrc with something like:
[[ -r ~/.bashrc ]] && . ~/.bashrc
But you can also tell your
.bashrc file to read your
.bash_profile file like yay:
[ -n "$PS1" ] && source ~/.bash_profile;
Not sure which is better, but I think I'm going with Option 2 above. I'm thinking this is smart because basically, it seems like
.bash_profile is used most often, so you want to still load it in the edge-case that your Terminal or whatever just so happens to load
.bashrc instead. Good? Good.
According to this SE question, the Mac OS X environment checks
.profile in this order. It will run whichever is the highest in the hierarchy, so, if you have
.bash_profile, it will not check
And I've been peeking through a few superuser dotfile repos and none of them are using the
.profile file, only
.bash_profile. They're also fond of using non-system dotfiles (e.g.
.aliases) which can then be loaded or read in using
.bash_profile. This just keeps things quite a bit tidier in your home directory, and since I always have confusion about what goes where it seems like a good strategy.
Put all my dotfiles into a repo. I like the name Tilde for this purpose. The local repo would not be my home directory, but kept somewhere else like Documents. This would require a
bash script that either symlinks or copies all the repo files into the home directory. Examples:
This page was last updated: 10-28-2019