Take the 2-minute tour ×

When I run screen it changes my prompt. How do I prevent this behaviour? For example:

$ echo $PS1
\[\e]0;\h:Prod\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
$ screen
$ echo $PS1
[\u@\h \W]\$

Interestingly, it does not do this on other machines. The machine in question is Redhat 4 update 4, with Screen version 4.00.02 (FAU) 5-Dec-03.

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

Try adding (assuming it's not already there) to your .screenrc file:

shell -$SHELL

This will give you a login shell when you initialize a screen session or create another terminal from within one.

share|improve this answer
I had 'shell /bin/bash' in my .screenrc, apparently it should have been 'shell -/bin/bash' or what you provided. –  Swoogan Jul 23 '09 at 18:37
add comment

Perhaps this is a customized variable that is set in the ~/.screenrc file?

share|improve this answer
Yes, check for setenv PS1 in global or personal screenrc –  radius Jul 23 '09 at 17:33
And what customized variable would that be? If you don't know the answer, don't answer. –  Swoogan Jul 23 '09 at 18:35
add comment

Many distributions check the type of terminal before setting the prompt. Ubuntu, for example, contains this little gem in the default .bashrc:

case "$TERM" in
    xterm-color) color_prompt=yes;;

Since screen uses its own TERM variable ("screen"), bash thinks it's not capable of displaying a fancy color prompt so it defaults to a simpler one. Screen is, of course, fully capable of the same complex prompts as a normal terminal.

So, to override this behavior, just hard-set your preferred PS1 options at the end of your ~/.bashrc file. Or, if you're feeling adventurous, find the test that checks the value of the TERM variable and modify it to accept "screen" in addition to "xterm-color".

share|improve this answer
add comment

Your Answer


