Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

user.name:some/repo (master) $

However, nothing I do seems to work. Even when I just try assigning to PS1 directly, it doesn't work:

user.name:~ $ echo $PS1
\u:\w $
user.name:~ $ PS1='oh yeah'
user.name:~ $ 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:

user.name:~ $ echo $PS1
\u:\w $
user.name:~ $ export PS1='oh yeah'
user.name:~ $ echo $PS1
\u:\w $

For reference:

user.name:~ $ $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.

user.name:~ $ 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
1  
Try readonly in the shell to see if PS1 is readonly. –  ott-- Jan 17 '13 at 19:39
2  
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? –  Rosarch Jan 22 '13 at 22:11
show 1 more comment

3 Answers 3

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 

try

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

Have you tried

export PS1='oh yeah'

Source

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

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.