Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't use terminal from error in .bash_profile

I added some things to my .bash_profile on my Mac OS X and they give an error. Here is my entire log of text when I start a terminal now:

Last login: Thu Oct 25 23:10:03 on ttys000
dirname: illegal option -- b
usage: dirname path
-bash: /bin/naoqi-bin: No such file or directory
-bash: exec: /bin/naoqi-bin: cannot execute: No such file or directory

[Process completed]

The problem is that since "Process completed", I can't use terminal. How do I access .bash_profile (I can't find out how from the finder), or how do I run terminal normally again so I can get that out of the .bash_profile file?

like image 930
jay Avatar asked Oct 26 '12 05:10

jay


3 Answers

Open Terminal, and go to File (or Shell) -> New Command. Type in open -e .profile (or substitute some other file instead of .profile), and hit Run. That should open TextEdit with the file you want to fix; you can remove the offending lines there.

like image 181
nneonneo Avatar answered Nov 03 '22 11:11

nneonneo


For completeness, here's another way: open TextEdit (or your favorite GUI text editor). In the open dialog, press Command-Shift-Period, and it'll display (and let you open) invisible files such as .profile. Remove the offending lines, save, and you should be good to go.

like image 45
Gordon Davisson Avatar answered Nov 03 '22 10:11

Gordon Davisson


You can run Bash with all startup scripts disabled to get around problems with startup scripts: choose Shell > New Command and run bash --noprofile.

See the Bash man page for more information about the Bash command-line options and startup files: x-man-page://1/bash

Also note that you can lookup and view man pages in Terminal even when your shell isn't working, by clicking on the Help menu and entering a topic in the search field. Terminal will display matching man pages. Choose one from the Help menu to view it in a new window. You can also open an x-man-page: scheme URL from any application.

like image 1
Chris Page Avatar answered Nov 03 '22 11:11

Chris Page