8

I was trying to customize my prompt in Terminal. To do this, I tried to edit .bash_profile using vim, but ended up with a .bash_profile.swp file. Following some posts I found online, I used the :recover command in vim, which created a new .bash_profile and then deleted the .swp file. However, now Terminal does not seem to work. When I open it, I get the below message:

-bash: c: command not found

-bash: end: command not found

[Process completed]

Does anybody know how to fix this?

Justin Boo
  • 10,132
  • 8
  • 50
  • 71
JChlip
  • 121
  • 1
  • 2
  • 3
  • This question is probably better suited for [Super User](http://superuser.com/). – Ansgar Wiechers Sep 12 '12 at 21:22
  • Does this answer your question? [How to restore .bash\_profile on a mac? None of my unix terminal are working](https://stackoverflow.com/questions/21067625/how-to-restore-bash-profile-on-a-mac-none-of-my-unix-terminal-are-working) – tripleee Jul 28 '20 at 05:32

3 Answers3

21

Something in your .bash_profile isn't as it should be. You seem to have a c and an end in it that bash interprets as command. If you post the contents of the file (without comment lines) either here or in a pastebin we'll probably be able to tell you where exactly those are.

Pressing Cmd+Shift+. in the file open dialog of TextEdit (or a real editor) should display dot-files in the dialog.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 1
    Tricky part is, that's a hidden file and terminal is the easiest way to view that file – Kylos Sep 12 '12 at 21:23
  • Ah, I wasn't aware of that technique! I'll have to remember it. – Kylos Sep 12 '12 at 21:36
  • I was able to fix it! You were right that I had weird commands in the file (probably due to my fumbling around in vim). The key was learning how to see hidden files in Finder, and therefore open up the file. Once I did that I was able to fixt it. Thank you so much! – JChlip Sep 12 '12 at 22:04
  • Came here and I didn't know about the TextEdit nifty trick! Thanks! – villancikos Jun 05 '17 at 23:31
  • Thank you. Nothing like accidentally clobbering your PATH and then shitting bricks when you realize terminal is life – OneChillDude Dec 05 '17 at 21:40
2

I used the TextMate option Show Hidden Files.

-1
  1. Open up TextEdit.
  2. Bring up the Open sheet.
  3. Hit "/".
  4. Type "~/.bash_profile" and then return.
  5. Open the (now highlighted) .bash_profile file.
Thane Norton
  • 174
  • 2