Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up PS1 so it displays the branch name on git: (master) $

However, nothing I do seems to work. Even when I just try assigning to PS1 directly, it doesn't work: $ echo $PS1
\u:\w $ $ PS1='oh yeah' $ echo $PS1
\u:\w $

Am I doing something wrong? Do I not have permissions to set this var? Do I have a syntax error?

I'm on Mac OS X 10.8.

I also tried: $ echo $PS1
\u:\w $ $ export PS1='oh yeah' $ echo $PS1
\u:\w $

For reference: $ $SHELL --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)
Copyright (C) 2007 Free Software Foundation, Inc.

Apparently PS1 is readonly. Interesting. $ readonly PS1
-bash: PS1: readonly variable

How do I make it not readonly?

share|improve this question
You're in a restricted shell where you're not allowed to change it? Or the value is set readonly? – ott-- Jan 17 '13 at 17:05
Are you sure you are running BASH (I agree, it sure looks that way but we're in the twilight zone here)? What is the output of $SHELL --version? – terdon Jan 17 '13 at 17:41
Try readonly in the shell to see if PS1 is readonly. – ott-- Jan 17 '13 at 19:39
Type just readonly on its own to list read-only variables. Typing readonly PS1 will set it read-only, which is the opposite of what you want. – mavit Jan 20 '13 at 17:29
How do I unset it? – Nick Heiner Jan 22 '13 at 22:11
up vote 2 down vote accepted

I would check you rc files to make sure PS1 isn't being defined readonly in them.

try the following:

user@server$ PS1='oh yeah :'
oh yeah :readonly PS1
oh yeah :PS1='different PS1 :'
bash: PS1: readonly variable
oh yeah :bash
user@server$ PS1='something else '
something else 


grep -E 'PS1=' ~/.bashrc <other rc files>
share|improve this answer

Have you tried

export PS1='oh yeah'


share|improve this answer
Yep - OP updated – Nick Heiner Jan 17 '13 at 15:40
Are you administrator user? Works for me. – LuckySpoon Jan 17 '13 at 22:15

Surprising, it should work and it's for sure not a permission issue.

Did you try double quotes export PS1="oh yeah" instead of export PS1='oh yeah' ?

share|improve this answer

You must log in to answer this question.

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