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

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

Right now I have $.

share|improve this question

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

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

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

Assuming you're using bash, you

export PS1='\$ '

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

share|improve this answer

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

share|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

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.

share|improve this answer

You must log in to answer this question.

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