https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
The issue is that Bash sources from a different file based on what kind of shell it thinks it is in. For an “interactive non-login shell”, it reads .bashrc, but for an “interactive login shell” it reads from the first of .bash_profile, .bash_login and .profile (only). There is no sane reason why this should be so; it’s just historical. Follows in more detail.
For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those files found.
/etc/environmentThis is the best place for variables that are system-wide. This includes extending variablePATHwith paths from/usr/localor forJAVA_HOMEDo not useexporthere or duplicate definitions./etc/xprofileVery little known but very useful for everyone who uses X window system. This is executed for every user that logs into X. It is very good choice for values that are valid for every user like/usr/local. Documentation./etc/profileand/etc/profile.d/*This is a good choice for non X systems but bad for X ones. Those files are read only by shells./etc/<shell>.<shell>rc. This is not a good choice because it is single shell specific. Also forget about X.~/.xprofileThe same as 2. This is executed when the user logs into X. The variables defined here are visible to every X application. A very good place for extendingPATHwith values such as~/binor~/gocode/binor defining user specificGOPATH. Your graphical text editor or IDE started by shortcut will see those values. Documentation.~/.profileIt will be visible only for programs started from terminal or terminal emulator. It is a good choice for systems where you do not use X window system.~/.<shell>rc. This is not a good choice because it is single shell specific.
/bin/bash
The bash executable
/etc/profile
The systemwide initialization file, executed for login shells
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits
~/.inputrc
Individual readline initialization file
If you have ever put something in a file like .bashrc and had it not work, or are confused by why there are so many different files — .bashrc, .bash_profile, .bash_login, .profile etc. — and what they do, this is for you. The issue is that Bash sources from a different file based on what kind of shell it thinks it is in. For an “interactive non-login shell”, it reads .bashrc, but for an “interactive login shell” it reads from the first of .bash_profile, .bash_login and .profile (only). There is no sane reason why this should be so; it’s just historical. Follows in more detail.
For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those files found.

No comments:
Post a Comment