2022-07-01
Bash dotfiles hard-won knowledgeBe advised that macOS is weird about starting new logins vs other interactive shells.
A Bash login (interactive) shell runs one of .bash_profile, .bash_login, or .profile (in descending order of preference). This should set environment variables, which will be inherited by shells it spawns.
It should also source .bashrc which will not be run automatically (.profile should first test to see if it's running in Bash or some other shell):
# if running bash if [ -n "$BASH_VERSION" ]; then # source .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fiA Bash interactive non-login shell runs .bashrc which should set functions and aliases.
A non-interactive shell runs none of the above. The default .bashrc begins by checking for interactivity to enforce this:
# If not running interactively, don't do anything case $- in *i*) ;; *) return;; esacNot sure if this is the only reason non-interactive shells don't run .bashrc or if there are others.
22:26