How do I make command prompt to end with # if I do sudo -s in mac terminal?

Right now I have $.

link|improve this question
2  
Uhh, I have a default installation, and it gives me #. How have you customized your environment? – Potatoswatter Oct 17 '10 at 3:12
feedback

migrated from stackoverflow.com Oct 17 '10 at 7:41

This question came from our site for professional and enthusiast programmers.

3 Answers

Assuming you're using bash, you

export PS1='\$ '

the \$ becomes the # or $ prompt depending on if your id==0.

link|improve this answer
feedback

There's an article on MacWorld about this: http://www.macworld.com/article/146550/2010/02/rootprompt.html

link|improve this answer
Link doesn't work. What did it say? What was the gist? Repost it here. – random Oct 18 '10 at 2:31
feedback

You need to export SUDO_PS1="prompt"

Instead of prompt, you write whatever your prompt should look like. For example:

export SUDO_PS1="\\$"

This will show only # when you're root. You can use the same line/placeholder for PS1, it'll show up as $ when you're a regular user.

To get the same prompt as a normal user when you're root, i.e. the following:

host:/Users/username root#

you need to enter this:

export SUDO_PS1="\[\h:\w\] \u\\$ "

Add the export line to your ~/.bash_profile if you want to keep it.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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