How can I change my bash prompt on Ubuntu?

3

1

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.

Andrew

Posted 2011-02-02T00:53:48.833

Reputation: 133

Answers

6

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

Gavin H

Posted 2011-02-02T00:53:48.833

Reputation: 196

Specifically what do you mean by [contents]? – None – 2011-02-02T01:04:54.423

@Andrew: the exact output from your echo command placed between single quotes (note that there should be a space after the last dollar sign). – Paused until further notice. – 2011-02-02T02:18:51.383

0

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. :-)

Keith

Posted 2011-02-02T00:53:48.833

Reputation: 7 263

PS, you may also be experiencing too much quoting if you paste the echo output. – Keith – 2011-02-02T04:34:37.057