I remember after a fresh install of os x, when i did a echo $PATH in the terminal, it responded with a blank line. Now after installing some tools over time, the $PATH variable has /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin value although my .bash_profile is blank. I was wondering where this value is being set?
Manipulating your PATH variable To make the change permanent, enter the command PATH=$PATH:/opt/bin into your home directory's . bashrc file. When you do this, you're creating a new PATH variable by appending a directory to the current PATH variable, $PATH . A colon ( : ) separates PATH entries.
The first edit to your Bash profile is to correct your PATH. PATH is an environment variable, which simply means that it represents some small bit of data while you use Terminal. Specifically, PATH contains a list of file system paths where the operating system can find programs to run.
Using a Profile File to Set your PATH User profiles are loaded at login. The PATH variable can be set in the ~/. profile file. As in all prior examples, we will need to source these changes to make them active for the current shell, but subsequent logins will persist the changes.
bash_profile in your user directory: C:\Users\<username>. If aliases for Git commands are needed, editing the . gitconfig file is usually sufficient.
Plausible candidates would be /etc/profile
and /etc/bashrc
; there's also /etc/paths
and /etc/paths.d
to look at. You might also need to look at $HOME/.profile
and $HOME/.bashrc
. There might be some other places that bash
looks too.
As of macOS Catalina, Mac defaults the shell to zsh (Z shell). This type of shell uses .zprofile
instead of .bash_profile
. To check if you are on bash or zsh, run echo $SHELL
. If the result is bin/zsh
, you are on zsh. In which case edit your ~/.zprofile
for env variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With