Can .bash_profile automatically run without sourcing it in iTerm2?

1

I am using iTerm2 in Mavericks OSX and made sure I updated to the latest version. My working directory inside preferences is set to Home Directory.

I was watching a tutorial on iTerm customization and this author I was listening to managed to have this scripts run automatically every time he just saves (":wq") out of Vim editor.

I am new to the Mac so I literally wasted a few hours trying to figure why my iTerm wasn't updating its color. It turns out I have to type "source .bash_profile" also.

From the video, the author taught how to download and install iTerm, typed "sudo vim .bash_profile" and pasted a script. I am sure there were not changes to the preferences other than the default. Did I miss something?

Thank you

Arrow

Posted 2013-12-30T00:17:13.830

Reputation: 193

After updating .bash_profile, did you open a new tab or new window of your terminal? Otherwise you have to source .bash_profile. Btw, using sudo for vim .bash_profile is really weird, so I would question everything else the author says. – janos – 2013-12-30T07:10:36.757

Link to video, please? – romainl – 2013-12-30T09:20:47.980

Like Janos said, using sudo to edit .bash_profile is odd, since .bash_profile is meant to be owned by the user (you), and su/sudo are used to do stuff as a different user. Sounds tacky, indeed. And on that matter, the only stuff you really need to do inside .bash_profile while using iTerm2 is stuff like path variables, PS1, sourcing and stuff. Changing stuff like, you said, background color would be easiest to do via iTerm2's own preferences. – krystah – 2013-12-30T14:10:25.953

Answers

0

The only other way to get the changes in your profile to be applied is to restart your terminal. This is because it is a script set to run at login. bash .bash_profile or exec ~/.bash_profile will not work as these commands will open a new bash process.

Lily Hahn

Posted 2013-12-30T00:17:13.830

Reputation: 1 215