It seems to me that every Linux distro that I SSH into or use locally (Mostly RHEL/CentOS and Debian/Ubuntu machines) have a different idea about which of
.bash_profile to run when I log in locally, when I SSH in, when I open tmux, or when running shell commands from within VIM.
I do have some scripts that I would like to run when I log in, be that via SSH or on the console. For instance, I would like to see the output of
df when I log in. I might log in from the computer itself (a Kubuntu desktop in a KDE session via Konsole), or I might SSH in from home to the same machine. However, these scripts should not run when e.g. running a shell command from within VIM. Should those be in
Likewise, I have some aliases that I would like made available from the CLI no matter if I logged in from the local machine (KDE and Konsole) or SSHed in. These should also be available from with VIM when running shell commands, and also in tmux. Should those be in
Edit: It seems that checking environment variables might help, using
IF conditions setting the things that I need. I would then put all the configurations into a third file
.bash_dotan, and then source that file from both
.bash_profile to ensure that it is always run. I could wrap the whole thing in an
IF [ALREADY_RUN] conditional to ensure that it won't run twice if both
.bash_profile are sourced. Are there any problems with this approach that I am not anticipating?