Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I did something to my PATH.

I was trying to add some new path and now none of the command like open ~/.bash_profile work, and echo $PATH only shows one path which is /Application/Filename.

Is there a way to fix this? This is my Mac OS X Lion.

share|improve this question

1 Answer 1

If you messed up your ~/.bash_profile you can always edit it by supplying the absolute path to the editor:

/usr/bin/nano ~/.bash_profile

Remove any changes to PATH and press CtrlO, then . Overwrite the file and reload your shell. Your path settings should be restored.

Other files that set your PATH on OS X are:

  • ~/.bash_login (if ~/.bash_profile doesn't exist)
  • ~/.profile (if ~/.bash_login doesn't exist)
  • /etc/profile
  • Everything in /etc/paths.d/
  • Finally, for GUI apps: ~/.MacOSX/environment.plist

Always remember to use the correct formatting for your new PATH, depending on whether you want your custom binaries to take precedence over system binaries:

export PATH=/some/other/path:$PATH

… or the other way 'round:

export PATH=$PATH:/some/other/path
share|improve this answer
    
Alternatively, open .bash_profile in any GUI text editor, e.g. TextEdit, by pressing Cmd-Shift-. in the Open… dialog to display hidden files and folders. –  Daniel Beck Sep 11 '12 at 18:37
    
awesome thanks. that worked :) –  sudesh Sep 11 '12 at 18:43
    
one fore question though, i do the export PATH.... on the terminal, and every time i reload the terminal the path is not set. how do i make it the permanent path ? –  sudesh Sep 11 '12 at 19:03
    
never mind i answered my own question. i used /usr/bin/nano ~/.bash_profile and wrote the path there, saved it and restarted the terminal, now everything is working fine. –  sudesh Sep 11 '12 at 19:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.