Muhammad
Muhammad

Reputation: 2814

How to set path in bash_profile on macos catalina 10.15?

Recently I have installed macos 10.15 (catalina) and I am installing some software which need to set their paths like java_home.

But I am not able to find .bash_profile or .zshrc ?

Upvotes: 10

Views: 19770

Answers (4)

ccoutinho
ccoutinho

Reputation: 4616

The $PATH is built by first looking into the content of the file /etc/paths, and then looking into every file in the folder /etc/paths.d. So, the $PATH in the pre-installed bash system installation contains every entry in these files, as well as in other shell types.

Additionally, if you want to append the $PATH just for zsh shells without affecting others (common use case since zsh is now the default shell in Mac OS), you can edit ~/.zshrc the following way:

export PATH=/path/available/only/for/zsh/shells:$PATH

The above command adds /path/available/only/for/zsh/shells to the $PATH, and the added path will only be available in zsh shells.

Upvotes: 0

Guillaume250
Guillaume250

Reputation: 522

macOS Catalina uses .zprofile instead of .bash_profile

cd && touch .zprofile && open .zprofile

This command will create and open a .zprofile file, and every path you save in the file will be permanently available on the terminal.

Android SDK paths for examples:

export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

Update for MacOS Monterey: Use .zshrc instead of .zprofile

Upvotes: 15

ingconti
ingconti

Reputation: 11666

go easy:

nano .zprofile

So for example for scala:

export PATH=$PATH:/usr/local/scala/bin

Ctl X and save...

Upvotes: 2

Aaron Kippins
Aaron Kippins

Reputation: 374

If you've never touched these files before then they won't exist on your machine to begin with you'll need to create them in your home directory. Then you'll be able to benefit from their capabilities.

[Edit]

To create it open your Terminal and enter the following commands.

cd ~/ This will put you in your home directory where these applications look for these files

touch .bash_profile .zshrc This will create the two files for you to edit and add your statements into. Since they start with a period they will be hidden so you'll either need to edit them with VIM or something of the sort or show hidden files. Then edit with the text editor of your choosing.

Upvotes: 9

Related Questions