This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what file is read when a terminal shell is started.

 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OS-X seems to be almost Unix-like that 99% of my shell hacking works fine. One problem: I can't figure out exactly which file is "source" when the shell starts. I've tried .bashrc, .bash_profile, .profile

I want to define my usual aliases, set the shell prompt, etc.

Something seems to be reading one of the scripts when the first one starts, but I'm not seeing it reproducibly.

I tend to have four or five shell window open at once, and I'd really like to have them automatically have my customizations loaded, without having to do a "source .bashrc" in each one.

Thanks
pat
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a bash instance starts, it will read .bash_profile in ~.

Changes made to this file after the instance is started will not be retroactive.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:When a bash instance starts, it will read .bash_profile in ~.

Changes made to this file after the instance is started will not be retroactive.


No problem with it being once-only.

I guess this asks, when is a bash instance started? Does each "terminal -> Shell -> new window"
start bash again? I ask because its not reproducible for me. Sometimes it works, and sometimes the aliases and prompt are not there. I have not been able to figure out what is happening when it works or when it does not work.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrell wrote:I guess this asks, when is a bash instance started? Does each "terminal -> Shell -> new window"
start bash again?

Yes, each window has its own instance.

I ask because its not reproducible for me. Sometimes it works, and sometimes the aliases and prompt are not there

Hmm, I have never experienced such issues.

Anything in there that could set off race conditions? (I can't think of anything that could, all I do is set up a few environment variables and aliases. But I got nothing else...)
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:When a bash instance starts, it will read .bash_profile in ~.

Changes made to this file after the instance is started will not be retroactive.


I don't have a ~/.bash_profile. I always update my ~/.profile.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually think that there are a number of different config files that bash looks for; e.g. .bachrc
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I actually think that there are a number of different config files that bash looks for; e.g. .bashrc

I fixed Bear's typos.

Yes, there are a bunch of them, that are fired off at assorted times. I've never understood exactly when which one goes off.

~/.bashrc, ~/.bash_profile, ~/.profile and some in /etc/

I never had to figure exactly when each was used. I know that in Linux, when you "su" or "login" there are rather strange rules as to which profile script is run. I can't remember details from back when I was really using HP-UX, or assorted BSD or even System 7 Unixes.

Right now, I've copied the files so all three of the ~/ profile-type files are the same. Which works, but its not very elegant.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic