If you use bash, add a line like this to ~/.bash_profile
:
PATH=~/bin:$PATH
PATH
is marked for export by default, so you don't need to use export
.
If both ~/.bash_profile
and ~/.profile
exist, bash only reads ~/.bash_profile
when it is invoked as an interactive login shell. ~/.profile
is also used by other shells that might not understand the same configuration options as bash.
Terminal and iTerm 2 open new shells as login shells by default. When bash is invoked as an interactive login shell, it reads ~/.bash_profile
but not ~/.bashrc
. The terminal emulators on other platforms often open new shells as non-login shells, so for example bash reads ~/.bashrc
but not ~/.bash_profile
. OS X users often use ~/.bash_profile
as the personal configuration file corresponding to ~/.bashrc
on other platforms, but it is also common to source ~/.bashrc
from ~/.bash_profile
or to tell Terminal or iTerm 2 to open new shells as non-login shells.
You can also change the path more globally in /etc/paths
or /etc/launchd.conf
, but in many contexts the path will still default to /usr/bin:/bin:/usr/sbin:/sbin
. And I have only really needed to change the path in shells and text editors.