How do I prevent GNU Screen from reseting my prompt? [closed]

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.


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.


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

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac

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".