1

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing about terminal/bash/shell. I can still cd ~/Desktop but it just says -bash-3.2$ instead of MyMacbook: ~Desktop $.

2 Answers 2

1

Others have had plenty of chances to mention the elephant in the room, so here it is:

Your prompt in the Bourne Again Shell is controlled by the values of the PS1, PS2, PS3, and PS4 variables. The relevant one here is the PS1 variable. It hasn't been set, so the Bourne Again Shell is displaying its default prompt, which is the expansion of the prompt string \s-\v\$ .

The prompt that you want can be achieved by setting the variable thus:

PS1='\h: \w\$'

There are at least two ways that you may have found yourself in this situation. The first, that 72DFBF5B A0DF5BE9 implies, is that you've suddenly started using the Bourne Again Shell where you were using the Tenex C Shell before. The Tenex C Shell uses different variables (prompt, prompt2, and prompt3) to control what is displayed as the prompt, and has different rc files.

The prompt that you want is achieved in the Tenex C Shell by setting the variable thus:

set prompt='%m: %~%$'

It will have been set up in your ~/.tcshrc (or /etc/csh.cshrc or ~/.login or …) script. Invoking the Bourne Again Shell won't have picked this up, of course. The answer is thus to go back to the shell that you were using before.

Another way, that heiglandreas states, is that you were indeed using the Bourne Again Shell, and had it set up with a PS1 variable in the ~/.bashrc (or /etc/profile or ~/.profile or …) script. Then something scrambled, or just simply renamed/deleted, that script. The answer in this case is to unscramble the script so that it sets PS1 in interactive shells once more.

A third possibility is that your PS1 variable is being set in ~/.profile rather than in ~/.bashrc, that it isn't being exported, and that you've invoked a secondary shell from your login shell. In which case the answer would be to exit the secondary shell, or ensure that your shell prompt is set in the rc file that is run for both login and non-login shells, rather than in the rc file that is only run for login shells.

For completeness, I'll mention another shell commonly used on Mac OS 10: the Z Shell. It uses the same variables as the Bourne Again Shell, and supports the many of the percent-style escape sequences of the Tenex C Shell.

The prompt that you want is achieved in the Z Shell by setting the variable thus:

PS1='%m: %~%#'

This would be set in the ~/.zshrc (or ~/.zprofile or /etc/zprofile or /etc/zshrc or …) script.

I mention this to emphasize the point that there are several shells on Mac OS 10 that one can use, that they all have separate sets of rc files, that their prompt variables aren't the same, and that those prompt variables can be set in one of several rc files in each shell. So you'll have to read the shell manuals and figure out which rc file has been damaged, or which shell you were heretofore using and should go back to, or whether you've simply invoked a subshell and not set your prompt variable in a way that subshells see.

Further reading

0

The default shell (or command-line interface) used in Mac OS X 10.0 through 10.2.8 is tcsh.

  • Open Preferences from the Terminal menu, click the “Startup” tab

  • Under “Shells open with” choose “Command (complete path)” and set the new shell

Then write "chsh -s /bin/tcsh" in the box

Or open Terminal app, then:

  • Choose Preferences from the Terminal menu.
  • Select the option "Execute this command (specify complete path):" then write /bin/tcsh
3
  • Whilst this may fix the symptoms by accident, it isn't the proximal cause of the problem and the questioner and others will be none the wiser about what's happening, and be able to deal with such situations in the future, from this. I suggest revising this answer to at least mention the elephant in the room, before someone else posts a more explicatory answer and the questioner grabs it. (-:
    – JdeBP
    Feb 5, 2014 at 9:58
  • @JdeBP, I have no idea, maybe ewk53 can tell us which version of Python and which version of Mac OS, so I can see if there is something specific about those versions which causes to change default shell Feb 5, 2014 at 15:29
  • Looks like installation changed the .bashrc file to get the new python binaries into the PATH variable. And it also seems that during that process either the PS variable has been altered or reset to some strange default. But without more infos as to HOW you installed WHICH version of python it's more like fortunetelling. Feb 5, 2014 at 17:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .