1

My Terminal does not show my username when I open a new window. Additionally, I can't execute any commands either. This is what is in my window:

...

Last login: Sat Oct  5 22:27:07 on ttys000
ls -1

[Process completed]

...

I cannot run pwd or cd or ls -1 etc:

Here are my startup settings:

Any suggestions?

slhck
  • 228,104
Jono.L
  • 11
  • 2
    Could you post your ~/.bash_profile please? Also ~/.profile if you have one (~/ means your user's home directory). Also check if it works if you open using a command (use /bin/bash) instead of "default login shell". – terdon Oct 06 '13 at 01:34
  • Basically what terdon said. The bash profile is probably either corrupt or missing. You may want to reference this other article which has more specific commands: http://superuser.com/questions/374204/all-commands-are-not-working-on-mac-os-x-lion – Hefewe1zen Oct 06 '13 at 01:40
  • Do you remember what you did before this problem started? (@Hefewe1zen, note that a missing .bash_profile is not a problem. In fact, this file does not exist by default.) – slhck Oct 06 '13 at 08:45
  • @terdon: how do I post my ~/.bash_profile and ~/.profile? I set things to /bin/bash instead of default login shell. No luck. Hefewe1zen: Looked at the article. When he says "start with "export PATH=/usr..." am I supposed to paste that into Terminal as a command? Tried that. No luck. slhck: I can't remember what I was doing. It was ages ago. Where do I find my .bash_profile? – Jono.L Oct 06 '13 at 23:18
  • If the file exists, it will be in your user's home directory ($HOME). Just get to it finder and add its contents to your question. – terdon Oct 06 '13 at 23:23
  • I still don't understand @terdon. I go to Finder > click on Macintosh HD > home > empty folder. So does the file not exist? How do I create it? – Jono.L Oct 07 '13 at 23:35
  • @Jono.L it is supposed to be in your home directory. On OSX I think it is /Users/<YOUR NAME>. It is your default directory where all your stuff is. – terdon Oct 07 '13 at 23:48
  • Thanks @terdon: Here is the contents of that file: PATH="/usr/local/bin:$PATH" source .bash_profile – Jono.L Oct 08 '13 at 01:17
  • @Jono.L please [edit] your question to add new info, it gets lost in the comments. Are those the contents of .bash_profile? If so, you are running an infinite loop and you should remove source .bash_profile. – terdon Oct 08 '13 at 01:27
  • @terdon - thanks so much you have solved this issue. I resaved the file removing what you said and I have my Terminal back! Many thanks – Jono.L Oct 08 '13 at 01:29

2 Answers2

1

This kind of problem is usually due to a command being run in one of bash's initialization files that never finishes so a prompt is never shown.

In OSX, the likeliest culprit is $HOME/.bash_profile. The simplest solution is to rename it and open a new shell. If that works, you can go back and copy anything you need from the original file. If you do this carefully, you should be able to pin point the original problem.

In this particular case, the problem is this line in .bash_profile:

source .bash_profile

The result of this is that .bash_profile will read itself over and over again in an infinite loop. Deleting that line will fix the problem.

terdon
  • 53,403
0

I worked on this similar issue for a whole day and I was eventually able to solve it with terdon's answer. Basically I am using zsh as shell and inside my ~/.zshrc file there is just a line of command: "source ~/.zshrc". In short, every time I open up the terminal, the zshrc file keeps sourcing itself and enters an infinite loop so you cannot prompt any command in your terminal. My solution was simply to delete the "source ~/.zshrc". Now hopefully everything work as normal