aspose file tools*
The moose likes Mac OS and the fly likes what file is read when a terminal shell is started. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "what file is read when a terminal shell is started." Watch "what file is read when a terminal shell is started." New topic
Author

what file is read when a terminal shell is started.

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

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

Joined: Jan 10, 2002
Posts: 60057
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

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

Joined: Jan 10, 2002
Posts: 60057
    
  65

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

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.


GenRocket - A Test Data Generation Platform
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

I actually think that there are a number of different config files that bash looks for; e.g. .bachrc
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4637
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what file is read when a terminal shell is started.
 
Similar Threads
setting PATH variable and linux
Where is Java Set up?
add entry to PATH using Mac OS X
setting PATH variable and linux
Export automatically...