0% found this document useful (0 votes)
10 views5 pages

How Do I Edit PATH Bash Profile On OSX

To edit the $PATH in Mac OS X, you need to create or open the .bash_profile file in your home directory. You can use a text editor like TextEdit or terminal commands such as nano or vim to add your export commands for ANDROID_HOME and PATH. If the .bash_profile file does not exist, you can create it using the command 'touch ~/.bash_profile'.

Uploaded by

syb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

How Do I Edit PATH Bash Profile On OSX

To edit the $PATH in Mac OS X, you need to create or open the .bash_profile file in your home directory. You can use a text editor like TextEdit or terminal commands such as nano or vim to add your export commands for ANDROID_HOME and PATH. If the .bash_profile file does not exist, you can create it using the command 'touch ~/.bash_profile'.

Uploaded by

syb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

How do I edit $PATH (.bash_profile) on OSX?

stackoverflow.com /questions/30461201/how-do-i-edit-path-bash-profile-on-osx

Learn, Share, Build


Each month, over 50 million developers come to Stack Overflow to learn, share their knowledge, and build their
careers.

Join the world’s largest developer community.

Google

Facebook

or

I am trying to edit an entry to PATH, as I did something wrong.

I am using Mac OS X 10.10.3

I have tried:

> touch ~/.bash_profile; open


~/.bash_profile

But the file editor opens with nothing inside.

My problem:

I am trying to install ANDROID_HOME to my PATH

I misspelled it, but when I closed the terminal and went back it was gone, so I tried again:

export ANDROID_HOME=/<installation location>/android-sdk-macosx


export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-
tools

This time, I typed the command correctly but, when I closed the terminal, my settings disappeared again.

How do I execute my desired settings?

If I was to edit bash.profile, how would I enter the above code?

Thanks!

4 Answers

1/5
up vote 122 down vote You have to open that file with a text editor and then save it.
accepted
touch ~/.bash_profile; open ~/.bash_profile

It will open the file with TextEdit, paste your things and then save it. If you open it
again you'll find your edits.

You can use other editors:

nano ~/.bash_profile
mate ~/.bash_profile
vim ~/.bash_profile

But if you don't know how to use them, it's easier to use the open approach.

Alternatively, you can rely on pbpaste. Copy

export ANDROID_HOME=/<installation location>/android-sdk-


macosx
export
PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

in the system clipboard and then in a shell run

pbpaste > ~/.bash_profile

Or alternatively you can also use cat

cat >
~/.bash_profile

(now cat waits for input: paste the two export definitions and then hit ctrl-D).

answered May 26 '15 at 15:31

Alessandro Vendruscolo

7,72222336

2/5
up vote A bit more detailed for beginners:
28 down
vote First get sure the .bash_profile file is existing? Remember that the .bash_profile file isn't there by
default. You have to create it by your own.

Go into your user folder in finder. The .bash_profile file should be findable there. ->
HD/Users/[USERNAME]

Remember: Files with a point at the beginning '.' are hidden by default.

To show hidden files in Mac Os:

defaults write com.apple.finder AppleShowAllFiles


YES

killall Finder

Found here: http://www.macworld.co.uk/how-to/mac-software/how-show-hidden-files-in-mac-os-x-


finder-funter-3520878/

If it's not existing, you have to create .bash_profile by your own.

Open terminal app and switch into user folder with simple command:

cd

If it's not existing, use this command to create the file:

touch .bash_profile

Second if you can't memorise the nerdy commands for save and close in vim, nano etc (the way
recommended above) the easiest way to edit is to open .bash_profile file in your favored code
editor (Sublime etc.).

Finder -> User folder. Right click -> open with : Sublime Text (or other code editor). Or drag it on
app in dock.

… and there you can edit it, pass export commands in new lines.

3/5
up For beginners: To create your .bash_profile file in your home directory on MacOS, run:
vote 2
down nano ~/.bash_profile
vote
Then you can paste in the following:

https://gist.github.com/mocon/0baf15e62163a07cb957888559d1b054

As you can see, it includes some example aliases and an environment variable at the bottom.

One you're done making your changes, follow the instructions at the bottom of the Nano editor
window to WriteOut (Ctrl-O) and Exit (Ctrl-X). Then quit your Terminal and reopen it, and you will
be able to use your newly defined aliases and environment variables.

answered May 31 at 16:14

Myles O'Connor

463

up vote Mac OS X doesn't store the path in .bash_profile, but .profile, since Mac OS X is a branch of *BSD
1 down family. You should be able to see the export blah blah blah in .profile once you do cat .profile on
vote your terminal.

answered May 28 '15 at 2:43

neemo810707

193

Your Answer

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password

Post as a guest

4/5
By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged osx path
terminal osx-yosemite or ask your own question.

5/5

You might also like