Monday, November 9, 2026
HomeApplemacos - How do I get env variables to load on terminal...

macos – How do I get env variables to load on terminal startup?

[ad_1]

This is without doubt one of the areas the place Linux and macOS differ so quite a lot of articles you discover solely partially apply to macOS. Primarily, on macOS, every Terminal tab runs a login shell.

  • For login shells, bash reads ~/.bash_profile or (if that is lacking) ~/.profile.
  • For interactive shells, bash reads ~/.bashrc.

So on macOS it does not really matter which of ~/.bashrc or ~/.bash_profile you select. It helps to be constant although and stick to 1 or the opposite.

To make surroundings variables obtainable in all future session, simply add them to the file of your selecting:

MYVAR='Whats up, world'; export MYVAR

PS: Personally I’ve take a look at -f ~/.bashrc && . ~/.bashrc in .profile and all definitions in ~/.bashrc. This covers each worlds (at the price of all the time loading some stuff which solely is relevant to Linux or macOS) and IMHO is nice sufficient for private use.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments