PATH
is a global environment variable that represents a list of directories bash looks in for executable files. The executable files for bash commands like grep
are all somewhere on your OS’s PATH
. We can add our own folders to PATH
to make our executables available as a command to bash. In this lesson we’ll learn how to add a new folder to our PATH
in .bash_profile and how to symlink an executable file into /usr/local/bin, which is in PATH
by default.
Note that in zsh, when modifying your PATH you to provide an absolute path, ~
is not expanded.
Next time you echo your path, try this: echo $PATH | tr : '\n' | cat
Note: starting with Catalina, macOS now uses zsh as the default shell instead of bash. zsh and bash are very similar, but zsh looks for a .zshrc
and .zprofile
instead. See https://support.apple.com/en-us/HT208050 for more info on the differences between the two.