5

When I start Terminal I can not control it. It starts executing an endless loop repeating that some alias does not exist. Because of this I am not able to edit this file using a program such as vim. Is there a way to update/delete .bash_profile and do not use Terminal at all, providing I have a replacement .bash_profile?.

  • What is some alias, exactly? Also, try doing cntrl-c (or the mac equivalent) that is frequently used on Windows/Linux to terminate a running command. It should free up your Terminal. – cutrightjm Dec 30 '13 at 7:59
  • I have put source after my custom alias. doing ctrl + c and opening new terminal does not help. – user55072 Dec 30 '13 at 8:06
7

There is a way to open hidden files, even if normally they are not shown in Finder. You can edit .bash_profile and comment out the lines that are causing problems or just delete everything to make the entire file empty.

  1. Open a plain text editor, for example TextEdit
  2. Press Command + o
  3. Navigate to your home directory
  4. If you don't see .bash_profile, then press Command + Shift + > to show hidden files
  5. Select .bash_profile, fix the problem, and save it
0

An alternative approach to solving your problem is to change your shell temporarily. To do this, go into Terminal's preferences. Change the option "shells open with" to "command" instead of "login shell". In the path box, type the name of some other shell on your system that has config files that aren't hosed. Since you're using bash, /bin/zsh might be a nice option.

Open a new terminal. You may now edit your files.

To get back to bash, simply change the "shells open with" option back to "login shell".

0

CTRL-C or CTRL-D should allow you to terminate the misbehaving process and return a responsive shell prompt in most cases. Please note on the Mac that I am referring to the Control key, NOT the Command key.

  • 2
    protip: enclose keyboard shortcuts in <kbd> tags, and they'll be formatted all pretty. – strugee Dec 30 '13 at 9:24
0

You could also save a new file that overwrites .bash_profile. Sublime Text allowed saving a file with a . in front of the name (albeit, with a few warnings).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy