
| From: Scott Sullivan via talk <talk@gtalug.org> | I suspect you have indeed run into the difference between: | | Interactive Login shell | Interactive Non-Login shell | Non-Interactive Login shell | Non-Interactive Non-Login shell | | .bashrc is called in almost all cases, .bash_profile only in some and bash | completions likely only in some. TMUX is lunching another shell that may be | non-login shell / non-interactive. So the question is why load completions, if | it's not a person the shell is responding to. This is certainly arcane but important knowledge. It is spelled out precisely in the bash manpage in section "INVOCATION". Too bad it is so complicated. Luckily INVOCATION is near the start of that manpage. That manpage doesn't capture the additional "features" of the default config files installed by my distro, Fedora. Your distro might well be different. The rules are heuristics. They attempt to capture this idea: A login shell sets up the environment for itself and to be inherited by its descendants. Other interactive shells will run ~/.bashrc if it exists. That is intended to set up the environment for this shell and not its descendants. The logic that implements this: An interactive login shell (or noninteractive shell with --login option) runs: /etc/profile then the FIRST of these that exists and is readable: ~/.bash_profile ~/.bash_login ~/.profile [The ~/.bash_profile takes precedence over ~/.profile because the ~/.profile was originally for the Bourne Shell and might not be tailored for bash. I don't know why .bash_profile and .bash_login are both supported.] An interactive non-login shell runs: ~/.bashrc [I don't understand why this isn't run for an interactive login shell. On my system, the default .bash_profile does run ~/.bashrc if it exists and is readable.] [On my system the default ~/.bashrc will run /etc/bashrc if it exists, not something documented in bash(1).] non-interactive non-login shell: nothing, unless BASH_ENV is set: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi [On my system, BASH_ENV is set to /usr/share/Modules/init/bash which is a 134-line script!] If bash is invoked with the name "sh" it behaves differently. It tries to mimic what the Bourne Shell would have done. Summary: a fairly simple idea has become encrusted with well-meaning complexity. It isn't magic, but may take some time to spelunk it on your particular system. I don't know whether different distros are consistent. I don't know what tmux does to invoke a shell. You could probable experiment to find that out. ps -f -q $$ should tell you how tmux invoked this shell.