.bash_profile
is a script that is executed each time you start a new shell. On Linux, it's called under different circumstances than .bashrc
, but on OS X, they work exactly the same way. Any command you add to the file will be run whenever you open a new terminal window (thus starting a new interactive shell).
$PATH
is a variable that tells the shell where to look for executable files - so when you type a command, the system will search each directory specified in that variable until it finds an executable program with that command's name.
The command export PATH=/usr/local/bin:$PATH
prepends the directory /usr/local/bin
to the current PATH, so it becomes the first directory searched by the shell.
.bash_profile
just a normal plain text file - you can edit it with any text editor, including vi
or nano
, or even a graphical editor like TextEdit. It's up to you - just remember to save it as a plain-text file.