Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Where is the setting that determines what the bash prompt looks like? Specifically on Arch, but I'm sure others would like to know for other distros too if it's different.

Speficially I'd like to use (K)Ubuntu's prompt

share|improve this question
add comment

4 Answers

up vote 10 down vote accepted

The environment Variables "$PS1" and "$PS2" set the prompt's look. You can check this howto in order to see all the different variables you can put in there. `

share|improve this answer
add comment

As tante said, you have to set the $PS1(left prompt) (and optionally $PS2(second line prompt)).

(Others variable exists on other shells like $RPS1 (right prompt) for zsh)

The best thing to do is to edit your .bashrc file in your home directory and add something like :

export PS1=...

I will give you an additionnal link that I always find useful because there's a good list of the avalaible colors.

share|improve this answer
2  
$PS2 is the prompt you get when writing a command over multiple lines, not the right prompt. The right prompt would be $RPS1 (and $RPS2 accordingly for multiple lines) on zsh - bash has no right prompt. –  sepp2k Oct 12 '10 at 9:56
1  
$PS2 contains the second promptline if a shell needs more input, not the right prompt. –  echox Oct 12 '10 at 9:57
    
Indeed, I've just got confused when I wrote this answer. Corrected. –  Elenaher Oct 12 '10 at 10:05
    
You should probably remove the bit about the right prompt altogether because that only exists in zsh and the question is about bash. –  sepp2k Oct 12 '10 at 13:47
    
@seppk : thanks for the comment. I have used zsh for many years and here at work I have to use bash. I didn't notice that RPS1 wasn't available on it. –  Elenaher Oct 12 '10 at 14:52
show 1 more comment

As others have said, this is determined by the environment vars PS1 and PS2.

Ubuntu's default ps1 is: ${debian_chroot:+($debian_chroot)}\u@\h:\w\$

So you'll want to run the following:

export PS1=${debian_chroot:+($debian_chroot)}\u@\h:\w\$

To run that every time you log in, put it in your ~/.bashrc file:

echo "export PS1=${debian_chroot:+($debian_chroot)}\u@\h:\w\$" >> ~/.bashrc
share|improve this answer
add comment

Since you asked specifically about Arch (well, it doesn't really matter, but it makes a nice excuse to add to the answers...), you should look at this entry in the Arch Wiki: Color Bash Prompt. And for even more fun, this thread in the Arch Forums: What's your PS1?. (Pages and pages of people trying to outdo each other with more and more elaborate prompts.... that's the typical Arch user for you.)

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.