Take the 2-minute tour ×
Server Fault is a question and answer site for 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

closed as off-topic by Andrew Schulman, masegaloeh, Scott Pack, Jenny D, Katherine Villyard Apr 12 at 14:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Andrew Schulman, masegaloeh, Scott Pack, Jenny D, Katherine Villyard
If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers 4

up vote 10 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

Had the same issue (no more custom prompt in screen) on a machine with SHELL -$SHELL and no setenv PS1 in screenrc, and no special test for (dumb) terminal in bashrc.

Setting the used $TERM:

$ echo $TERM
urxvt-unicode-256color

in screenrc got my custom prompt back while under Screen:

- #term xterm-256color
+ term urxvt-unicode-256color

PS: another account had no need for this, but bashrc tests for dircolors and a modern terminal this way1:

if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then
PS1=<my fancy prompt>

I believe this works as well:

if [ "$TERM" != "dumb" ]; then
PS1=<my fancy prompt>
share|improve this answer

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.