1

When I open the terminal, the prompt is as follows:

<computer-name>:~ <username>$

When I run bash in the Mac terminal, it changes my prompt to the following of course:

bash-3.2$

However, this surprises me, because my shell is already bash: I know this because when I run the following echo command it yields bash:

echo $SHELL 
/bin/bash

So, why does the prompt change, when bash is already my default? Is there something I'm misunderstanding here? Thank you.

4
  • What is returned by echo $PS1 before and after running bash ? Commented Jun 17, 2015 at 18:02
  • 1
    /bin/bash is version 3.2 in Mac OS X; is your terminal configured to run a different bash that's not in your path on startup? Commented Jun 17, 2015 at 18:07
  • 1
    Try bash -l; that will run it as a login shell, and it should give you your normal prompt. Commented Jun 17, 2015 at 18:19
  • So, echo $PS1 prints \h:W \u\$ when using <computer-name>:~ <username>$, and it prints \s-\v\$ when using bash. What, if anything, does this tell us? Thanks. Commented Jun 18, 2015 at 6:22

2 Answers 2

2

Prompt is defined by PS1 variable. See

echo $PS1

in both cases. Most likely when you login, some of start scripts change the value of PS1. Inspect files:

~/.bash_profile
~/.bash_login
~/.bashrc
~/.profile
/etc/profile
/etc/bash.bashrc

For more information how bash starts, see INVOCATION section in man bash and for PS1 and others prompt related variables see PARAMETERS section.

Sign up to request clarification or add additional context in comments.

Comments

0

Your PROMPT (aka PS1) changes because when you just open terminal, it, probably, run bash either: 1) as login shell (in that case bash, probably, has special settings for login shell mode (look at ~/.bash_profile or /etc/profile (although, /etc/profile should load even for non-login shells)));

2) with TERM value, different, that you have in manually called (actually, I doubt it);

3) with it's own custom bashrc or something like that;

Anyway, you can edit ~/.bashrc (for example, copy PS1 there from ~/.bash_login and get what you want)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.