Permanently saving changes to $PATH [duplicate]

I have ruby and homebrew running for a while and I'm starting to play with Bash. I have encountered a problem with my PATH variable as echo'd:

/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin??n’export

As you can see, there is both redundancy and junk at the end int he form of illegal characters (causing a host of other issues). I can change the PATH with

export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"

which does indeed return the desired PATH when echo'd:

/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

But I can't figure out for the life of me how to save the PATH so that it doesn't reset on reopening. I don't need to add paths. I just want to make this the new value of that variable. Please, how can I make this change permanent?


You can simply add your export PATH... line in your bash_profile file. This file is run every time you start terminal and will modify your PATH variable as you want. You can open/edit this from anywhere in terminal using

 open ~/.bash_profile

You probably also want to check that there are no conflicting export PATH... statements that overwrite each other or something.