by yes_or_gnome · 11y ago · 0 comments
http://www.gnu.org/software/bash/manual/html_node/Bash-Start...
.bashrc - is for non-login shells (not run with --login option). This is where you want to configure your PATH, so all shell invocations behave the same. You'll likely have the PATH modification as the first line, then you may want to source the system rc file (/etc/bashrc), and, usually, you'll have some interactive-only modifications such modifications to PS1.
.bash_profile(, .bash_login, or .profile) - is used for login shells. You may have some reason to run some commands (personal MTOD!?). There may be good reason to manipulate PATH here, but I can't think of one. (The rbenv tool from the Ruby community insists using .bash_profile; I don't know why.) Finally, you end by sourcing the .bashrc.
On the other hand, things like shell aliases are not automatically shared to child processes, so you need to set them up afresh in every shell you launch. Therefore, ~/.bashrc is the place for those things.
It's an early optimization, that generally no longer is worth the complexity. I put everything in .bashrc. I'm more likely to break out a separate environment shell file by related or complex tasks to assist in testing/debugging my environment.
That may explain why so many github projects recommend adding PATH and other env variables to .bash_profile.