• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what file is read when a terminal shell is started.

 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...)
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic