I found this diagram on SO at one point but I can’t find the post and it is the best explanation I have found for how all of the files work for bash and zsh, each color is an individual path of execution (eg, follow the red line).
Bottom line though, it only really matters if you are overriding something that is already defined, for example I tell my users to use zshrc and I provide defaults and common things in zprofile because zshrc is executed last when they login.
I bet each step/arrow/decision had a good reason at some point, but most of them probably back when computers lived in caves and hunted their tapes using spears and rocks.
I feel like we’re slowly reaching a point where the complexity is collapsing in on itself - just look at the absolute chaos a modern web app is.
Is this a diagram for how it should work? Not how it actually works? Like I put my stuff in the ~/.bashrc, mostly because I think the debian one says like “put your fun stuff below here” or something. The green and grey lines go through the ~/.bashrc, but both of them go through the “no login” bubble in the diagram. But I know my ~/.bashrc works, so the diagram is a suggestion?
A lot of systems will call various inits from others to give you a more simplified flow. (Closer to what zsh does.) Check out some of those files in /etc/ it is calling as well as ~/.bash_profile. Or, you might not even be in a login shell!
I found this diagram on SO at one point but I can’t find the post and it is the best explanation I have found for how all of the files work for bash and zsh, each color is an individual path of execution (eg, follow the red line).
Bottom line though, it only really matters if you are overriding something that is already defined, for example I tell my users to use zshrc and I provide defaults and common things in zprofile because zshrc is executed last when they login.
I feel like I couldn’t make this more confusing if I tried. What is doing on with the golden arrows around
/etc/profile
??That’s decades of legacy for you…
I bet each step/arrow/decision had a good reason at some point, but most of them probably back when computers lived in caves and hunted their tapes using spears and rocks.
I feel like we’re slowly reaching a point where the complexity is collapsing in on itself - just look at the absolute chaos a modern web app is.
I was referring more to the graphical representation that the actual flows.
Agreed! It’s cathartic to see it laid out so terrifying. Now I feel less bad for never understanding it.
Is this a diagram for how it should work? Not how it actually works? Like I put my stuff in the ~/.bashrc, mostly because I think the debian one says like “put your fun stuff below here” or something. The green and grey lines go through the ~/.bashrc, but both of them go through the “no login” bubble in the diagram. But I know my ~/.bashrc works, so the diagram is a suggestion?
A lot of systems will call various inits from others to give you a more simplified flow. (Closer to what zsh does.) Check out some of those files in
/etc/
it is calling as well as~/.bash_profile
. Or, you might not even be in a login shell!Here’s the seemingly original source for those who like to know.