newb question about osx .bash_profile

Okasa

Member
Jan 22, 2005
168
0
0
im trying to set up my terminal window to automatically run code when opened. im running osx 10.3.9, and i have heard many people talk about using ~/.bash_profile however, i cannot seem to get the code, for testing purposes only has "ls", to run when the terminal is launched. source .bash_profile works fine btw. can someone give me a step-by-step instruction on how to set this up? thanks!

p.s. how can i ensure that -noprofile isnt enabled?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I think I ended up having to make the changes to either ~/.bashrc, or the bash files in /etc on my powerbook.
 

Okasa

Member
Jan 22, 2005
168
0
0
the ~/.bashrc and the ~/.bash_profile apparently do not come installed with the operating system if i am correct in what i heard, they have to be created by the user. however, i did mess with /etc/profile and /etc/bashrc (the non-hidden one), to no avail.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
You can copy the ones in /etc to your home directory. The shell is _supposed_ to check for the existance of the files in your home dir and use those if they exist.
 

Okasa

Member
Jan 22, 2005
168
0
0
could you give me the code you have in your .bash_profile, or at least any formatting that i may not know of?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Okasa
could you give me the code you have in your .bash_profile, or at least any formatting that i may not know of?

I'm at work now, but I'll try to remember to see what I can figure out in the morning.

There shouldn't be anything fancy, try something like bash -l in your terminal. If your changes come up, the Terminal.app program isn't making bash a "login" shell. There should be an option to add this or at least add the -l flag to bash in the preferences.
 

Okasa

Member
Jan 22, 2005
168
0
0
those are 2 different things im about 90% sure. mainly as ive seen both, or are you saying i need to put it in "/.profile"?
 

Okasa

Member
Jan 22, 2005
168
0
0
for the time being, ive found i can specify a file to source each time i open a new terminal. for now that will be ok, but im still curious on how to do it properly.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Ok, I added ls to /etc/bashrc and it works fine. Apparently it doesn't check ~/.bashrc. To get it to do so, add the following to /etc/bashrc

if [ -e "${HOME}/.bashrc" ] ; then
source ${HOME}/.bashrc
fi
 

hopejr

Senior member
Nov 8, 2004
841
0
0
Like I said, it's ~/.profile. On linux systems it's ~/.bashrc, but OS X, being based on BSD uses ~/.profile. Try it.

BTW, ~/.bashrc works in xterm in X11.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: hopejr
Like I said, it's ~/.profile. On linux systems it's ~/.bashrc, but OS X, being based on BSD uses ~/.profile. Try it.

BTW, ~/.bashrc works in xterm in X11.

I wonder why Apple changed that, bash should be the same no matter what platform you use. :|
 

hopejr

Senior member
Nov 8, 2004
841
0
0
I don't think it was Apple that changed it. I heard it's just a FreeBSD thing.