$PATH is just a variable containing a string. To put something in front:
% PATH=/usr/local/bin:$PATH
% echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
This is not dangerous, since it only applies to the current shell you have open (it will not affect the path for your system or other shells).
To change the path automatically for all shells you open, put it in ~/.profile
. You can create this file if it doesn’t already exist.
In ~/.profile
:
homebrew=/usr/local/bin:/usr/local/sbin
export PATH=$homebrew:$PATH
export
makes the variable available to any child processes of the shell.