jay
jay

Reputation: 477

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?

Upvotes: 7

Views: 13689

Answers (4)

Chris Page
Chris Page

Reputation: 18703

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.

Upvotes: 1

Aaron Lelevier
Aaron Lelevier

Reputation: 20838

I could not open it with:

open ~/.bash_profile

But when I entered

sudo open ~/.bash_profile

It worked and I was able to open the file!

Upvotes: 0

nneonneo
nneonneo

Reputation: 179717

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.

Upvotes: 17

Gordon Davisson
Gordon Davisson

Reputation: 126048

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.

Upvotes: 7

Related Questions