Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

up vote 8 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
1  
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

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

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

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

share|improve this answer

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.