Creating a .bash_profile on your mac

A typical install of OS X won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have.

  1. Start up Terminal
  2. Type "cd ~/" to go to your home folder
  3. Type "touch .bash_profile" to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
  5. Type ". .bash_profile" to reload .bash_profile and update any functions you add.

Thank you so verry much!

Thank you so verry much!

Hi, Thanks for your comment,

Hi,
Thanks for your comment, this is first time when any thing from some one's blog run in first shot. Much appreciated.
--
Sumit

I'm pretty new to the world

I'm pretty new to the world of the Mac. Following your instructions I've gone into Spotlight, found Terminal, clicked on it. A black command window opens up, when I type in the touch command it fails.

Last login: Thu Oct 22 06:08:40 on ttys000
92:~ stephengray$ cd ~/
92:~ stephengray$ touch .bash_profile
-bash: touch: command not found
92:~ stephengray$

This doesn't sound great does it? I've 'played around' trying to get Clang working in the past so perhaps I've messed up a little on the way. After doing some searching it says that the .touch, ls commands come from CoreUtils. Perhaps I have just messed up my PATH structure of something but sadly I've got no idea on how to fix it. Any help would be really appreciated!!

Cheers

Steve

Hey Steve, "touch" is really

Hey Steve,

"touch" is really just a shortcut way to create the .bash_profile file. Another way would be to just type "edit .bash_profile" That SHOULD open a new file in TextEdit or something similar. Whatever way you can manage to create a new file should work. Let me know if that doesn't work for you...

Hi Patrick, many thanks for

Hi Patrick, many thanks for the quick response. I think there's an issue with my Mac as if I open up a terminal window and type in edit .bash_profile I get the following:

Last login: Thu Oct 22 16:48:47 on ttys001
92:~ stephengray$ cd ~/
92:~ stephengray$ edit .bash_profile
-bash: edit: command not found
92:~ stephengray$

:-/ Doesn't look good does it?

Cheers
Steve

mmm I think I've got myself

mmm I think I've got myself to blame on this one when I was trying to get clang installed before

92:~ stephengray$ echo $PATH
/Users/stephengray/documents/Clang/:
92:~ stephengray$

I guess I should have more entries than this?

Thanks for an help you can give Patrick!

Regards

Steve

Hm, you could try typing

Hm, you could try typing "pico .bash_profile" and creating/editing a file that way. There's also vim, but that's a bit harder to navigate.

By the way, my

By the way, my $PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin

Thank you so much for this

Thank you so much for this tutorial!
Easy and Straight to the point!
Keep it up!

Hi. Thanks for posting the

Hi. Thanks for posting the above, but its not working for me for some reason. When I type in the command cd~/ I just get "no such file or directory. But when I type in the command cd~\ I get > (symbol) allowing me to type in commands.

If I use the back slash \ and type in touch .bash_profile, I just get command not found. Can you provide any insight to what I might be doing wrong.

Disregard my earlier comment.

Disregard my earlier comment. I was not entering the command properly.

What I am still confused on is when the .bash_profile opens up with text editor what am I supposed to do? Am I supposed to write something in there and save it?

Also instruction number 5 is not that clear to me. Could you repost instruction number 5 again please? Am I to type . . bashrc (with 2 dots in the terminal window to reload everything. Sorry to bother. I hope this thread is still active.

Finally got it working.

Finally got it working. Thanks for the site.

Thank you! Good work.

Thank you! Good work.

Thank you, very much! Simple,

Thank you, very much!
Simple, concise and works!

Got my 1st Mac, and thanks to

Got my 1st Mac, and thanks to this website. I can be able to make it works with my Mac.

How did you get the bashrc

How did you get the bashrc bit working?

Great information. I got

Great information. I got lucky and found your site from a random Google search. Fortunately for me, this topic just happens to be something that I've been trying to find more info on for research purpose. Keep us the great and thanks a lot.

Worked for me when I used ' .

Worked for me when I used ' . .bash_profile ' for the last line, and ditto Sumit this worked right away. Thank you!!

Wow Thanks! . .bash_profile!

Wow Thanks!
. .bash_profile! I didn't execute this before I started panicking!
kinda confusing though.. at first I tried with ..bash_profile, thinking the two dots were not seprated:D

Anyways Thanks! It helped!!!

Thanks a lot!!! It works for

Thanks a lot!!!
It works for me and save my time :)

Nice nam ... keep going!!

Nice nam ... keep going!!

Yes, after reading the

Yes, after reading the comments I also got it working.
The last part is really a little confusing.
But thank you for your efforts ;)

I was having some issues with

I was having some issues with the touch .bash_profile command then I realized that there is a space between "touch" and ".bash_profile"... I retyped the command and it worked!

thank you patrick pico

thank you patrick pico .bash_profile worked for me

its really useful. thank you.

its really useful.
thank you.

VarunBatra-iMac:~ varunbatra$

VarunBatra-iMac:~ varunbatra$ ..bashrc
-bash: ..bashrc: command not found

I am getting this error again and again. Any idea about what i am doing wrong?

You need to type ". .bashrc"

You need to type ". .bashrc" (note the SPACE between the first and second ".")

I´m getting the same error,

I´m getting the same error, even if I introduce ". .bashrc" with the space in between. It seems that there´s no .bashrc file in my ~/ directory.

Any suggestions?

I think there may have been a

I think there may have been a typo. Please try the updated #5.

Thanks!

Thanks!

muy buena, me ayudo mucho so

muy buena, me ayudo mucho
so good, hepfull me

Thanks, just searched and

Thanks, just searched and found this. Simple and easy, I like it.

It didn't work for me. What

It didn't work for me. What should I do?

Thanks a lot!! Very Useful.

Thanks a lot!! Very Useful.

Thank you! your post helped

Thank you! your post helped me a lot.

Just FYI, I think I had to close my terminal and open it again to make my new function work. However, I'm not 100% sure about this.

Thanks a lot

Thanks a lot

Thank you so much, what a

Thank you so much, what a brilliant sollution.

Hello everything was working

Hello everything was working until I grabbed the home icon accidentally and dropped it on Terminal now it gives me this error: -bash: cd~/: No such file or directory
and the applications from user got deleted.

I would appreciate your help!

Thanks.

I ALMOST have it, but for the

I ALMOST have it, but for the last step. I have ensured that I included a space to separate the two dots, but get this:

[Sibs-MacBook-Pro:~] mike% . .bash_profile
.: Command not found.

Any ideas?

Hmm, try typing "source

Hmm, try typing "source .bash_profile" instead...

Either way, it's the

Either way, it's the shorthand of just closing your shell/terminal and re-opening it. So, if all else fails, just turn it off and on again so to speak ;)

ha ha haa.... I made it..

ha ha haa.... I made it.. thanks Patrick..

Love your work, but yeah, I

Love your work, but yeah, I had issues with not realising that its . .bash_profile (not ..bash_profile) :)

can you pl help. am not able

can you pl help. am not able to create the bash file. the first step itself is giving an error
anujjosh$ "cd ~/"
-bash: cd ~/: No such file or directory

"cd" or "cd ~" might work

"cd" or "cd ~" might work (leaving off the slash).

greatly appreciated.

greatly appreciated.

awesome!!

awesome!!

thanks for your entry. I was

thanks for your entry.
I was lucky I got into your blog and don't have to search over a haystack.

Thanks so much Patrick

Thanks so much Patrick

A thousand thanks, keep up

A thousand thanks, keep up the good work :D