I am trying to set my shell prompt by inserting the following line into .bashrc in my home directory:

export PS1="\[\e[01;36m\][\u]\[\e[0m\] \[\e[01;37m\]\W\[\e[0m\] $ "

I save this file and re-open bash, but it doesn't change. When I issue the command echo $PS1, the console shows


which is the default prompt. I looked around .bashrc and do not see the PS1 environment variable being set anywhere except the line that I inserted shown above.

This works on my local machine, but with my account on a remote server it won't stick. How do I make the custom prompt go into effect?


  • Are you sure you are using bash? Try echo $SHELL.
    – ssmy
    Commented Mar 10, 2013 at 22:34
  • Yes. On startup, issuing echo $SHELL returns /bin/bash
    – tomocafe
    Commented Mar 10, 2013 at 22:35
  • Is it possible your .bashrc is being called by .bash_profile or .profile (or that .bashrc is calling them), and so something is overriding them later?
    – killermist
    Commented Mar 10, 2013 at 22:55

1 Answer 1


The problem here is the difference between login and interactive shells. See here for a summary.

~/.bashrc is only read when starting an interactive (non-login) shell. When you sshinto a remote machine, you are running a login shell so ~/.bash_profile or ~/.bash_login or ~/.profile (in that order) are read instead. You can check this by running bash after loging on to the remote server, that will start an interactive shell, ~/.bashrc will be read and your modified prompt will appear.

To change the prompt that appears when you ssh, set $PS1 in ~/.bash_profile:

export PS1="\[\e[01;36m\][\u]\[\e[0m\] \[\e[01;37m\]\W\[\e[0m\] $ "

Alternatively, you could call ~/.bashrc from ~/.bash_profile or ~/.profile:

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc

The if [ "$BASH" ]; then is useful when using ~/.profile since it will be read by non-bash shells.

  • I've moved the export statement into .profile, but it still doesn't work. I didn't have a .bash_profile file, so I created one and stuck the statement in there, but to no avail. I also tried to run an interactive shell after logging in, but it does not set PS1 either. Do you have any ideas as to what's going on? Thanks for your help!
    – tomocafe
    Commented Mar 11, 2013 at 2:46
  • @EvanW does it work if you run the export command directly from the terminal?
    – terdon
    Commented Mar 11, 2013 at 2:54
  • 1
    Ah -- I figured it out. At the end of my .profile file, a shell script was called that modified PS1 again. I moved my export statement to after the source statement calling the script and it works fine. Thank you!
    – tomocafe
    Commented Mar 11, 2013 at 2:56

You must log in to answer this question.

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