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 have one account on an Ubuntu server with the correct PS1 variable and I want to make one of my other accounts on the same server have the same PS1 variable, so that my prompt on this new account (when I ssh into the machine) is the same as the original account.

Is there a way that I can pass this PS1 variable between accounts so the prompt is the same?

I have tried printing it out, copying the output, and then reassigning it to PS1 on the new account, but it just doesn't work.

Here is what is printed when I type echo $PS1:

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$

I want to assign that prompt (shown above) to my new account.

share|improve this question

migrated from stackoverflow.com Feb 2 '11 at 1:27

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

add comment

2 Answers

up vote 6 down vote accepted

set

PS1=[contents]

in the .bashrc file for the user in question. For example, a typical situation for user bob would be in:

/home/bob/.bashrc
share|improve this answer
    
Specifically what do you mean by [contents]? –  Andrew Feb 2 '11 at 1:04
    
@Andrew: the exact output from your echo command placed between single quotes (note that there should be a space after the last dollar sign). –  Dennis Williamson Feb 2 '11 at 2:18
add comment

You can't just copy the output from the screen because the prompt contains terminal escape codes that get consumed by the terminal (to make color, for example). So it's not the same set of characters. You need to edit your ~/.bashrc and copy the PS1=... line from your other machine to your new one. That is, use the source. :-)

share|improve this answer
    
PS, you may also be experiencing too much quoting if you paste the echo output. –  Keith Feb 2 '11 at 4:34
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.