Friday 26 June 2020

How to edit .bash_profile and modify or add $PATH on OSX ?

First, make sure the .bash_profile file is existing?  Remember that the .bash_profile file isn't there by default. You have to create it on 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 Finder:  Press: Command + Shift + . 
If it's not existing, you have to create .bash_profile on 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 
Now we can edit .bash_profile using many ways mentioned below.

vi ~/.bash_profile 
or 
subl ~/.bash_profile 
or 
mate ~/.bash_profile, depending on your favourite editor.

You have to open that file with a text editor and then save it.
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_profilemate ~/.bash_profilevim ~/.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-macosxexport 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).



References:

0 comments:

Post a Comment

Contact

Get in touch with me


Adress/Street

Bangalore, India