can't use terminal from error in .bash_profile

12,956

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
12,956
jay
Author by

jay

Updated on June 13, 2022

Comments

  • jay
    jay almost 2 years

    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?