.[x]profile, .[x]rc files

Tags:

I always forget what those .bash_profile, .bashrc, .zprofile, .zshrc do, so I’m summarizing them here:

  • .[x]profile: runs when login
  • .[x]rc: runs for an interactive shell

What does this mean?

  • If I logged in and a script is runs before interactive shell starts (aka non interactive login shell), only .profile runs at the point.
  • If I login in and a shell opens, it runs both .profile and .rc.
  • If there’s something which needs to change everytime I open a shell, it should go to .rc.
  • If a GUI application needs an env variable, it looks like those variables should go to .profile since it’s not an interactive shell, but .rc often runs in that case too.

It’s natural for some code appear in both .profile and .rc, e.g., pyenv recommends it if certain non interactive login shell script relies on the pyenv.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *