简体   繁体   中英

Is there an equivalent to the Linux .bash_profile for Mac OS?

Answers like this one show that on a Mac, .bash_profile gets run every time a new terminal window opens.

Is there a shell config file for Mac OS that only runs when Terminal.app starts running and doesn't run for every new terminal window?

Is there a shell config file for Mac OS that only runs when Terminal.app starts running and doesn't run for every new terminal window?

There isn't, and there's no need to.


In Linux, the GUI frontend acts as a sh login shell, executing /etc/profile and ~/.profile . Any shell run in a terminal emulator in that session will thus inherit the resulting environment.

In MacOS, the GUI frontend does not do that. So to compenstate, Terminal.app is set up by default to run a shell inside it as a login shell, creating its own "login session" with the necessary environment.

As such, there's no need to run anything separately on Teminal.app's start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM