GNU Screen affects the display of the terminal

bashgnu-screenurxvtvim

I am using urxvt and running screen. My issues:

  • Underlining – some of the scripts I run have colored output. They are fine if I'm just running through urxvt, but when in screen, they are underlined and it makes it difficult to read
  • Scrollback – when switching between windows in screen and running commands, the scrollback for each window is messed up. Instead of only being the scrollback for the current window, it combines all the scrollback. So if I go from vim to another window and scroll up, I'll see my vim window.
  • Quiting Vim – When I quit vim in just urxvt, it hides the editor and I can see the prompts and commands I was running before calling vim. From inside screen, when I quit vim, I am given a prompt underneath the vim editor. I'd like for it to hide the editor like it does when not running urxvt.

Any ideas?

# terminfo and termcap for nice 256 color terminal                                                                                                                                                                  
# allow bold colors - necessary for some reason
attrcolor b ".I" 

# erase background with current bg color 
defbce "on" 

#terminfo rxvt-256color 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
#terminfo screen 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'

# Skip the startup message
startup_message off

term xterm

screen  
title VIM

screen ssh bcooper@loki 
title Loki

screen ssh ...
title Logs

screen  
title Mac

select 1
select 0

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'

bind ( eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"
bind ")" eval "exec sh -c 'pbpaste > /tmp/screen-exchange'" 

#Use the alternate screen - helps with quiting vim and not messing up current window
altscreen on

SETTINGS – Local Machine

declare -x COLORFGBG="15;0"
declare -x COLORTERM="rxvt"
declare -x COMMAND_MODE="unix2003"
declare -x DISPLAY="/tmp/launch-kxXxmI/org.x:0"
declare -x OLDPWD
declare -x declare -x PS1="[\\W]\$ "
declare -x SHELL="/bin/bash"
declare -x SHLVL="2"
declare -x SSH_AUTH_SOCK="/tmp/launch-QMhdZD/Listeners"
declare -x TERM="xterm"
declare -x TMPDIR="/var/folders/Ot/Ot3uMpWLF-aFeojPSVbhHU+++TI/-Tmp-/"
declare -x USER="briancooper"
declare -x WINDOWID="10485766"
declare -x X11_PREFS_DOMAIN="org.x.X11"
declare -x __CF_USER_TEXT_ENCODING="0x1F5:0:0"

Local Machine w/ Screen

declare -x Apple_PubSub_Socket_Render="/tmp/launch-cnvvgY/Render"
declare -x COLORFGBG="15;0"
declare -x COLORTERM="rxvt"
declare -x COMMAND_MODE="unix2003"
declare -x DISPLAY="/tmp/launch-kxXxmI/org.x:0"
declare -x OLDPWD
declare -x PS1="[\\W]\$ "
declare -x SHELL="/bin/bash"
declare -x SHLVL="3"
declare -x SSH_AUTH_SOCK="/tmp/launch-QMhdZD/Listeners"
declare -x STY="491.ttys000.brian-coopers-macbook-pro-2"
declare -x TERM="xterm"
declare -x TERMCAP="SC|xterm|VT 100/ANSI X3.64 virtual terminal:\\
        :DO=\\E[%dB:LE=\\E[%dD:RI=\\E[%dC:UP=\\E[%dA:bs:bt=\\E[Z:\\
        :cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:cm=\\E[%i%d;%dH:ct=\\E[3g:\\
        :do=^J:nd=\\E[C:pt:rc=\\E8:rs=\\Ec:sc=\\E7:st=\\EH:up=\\EM:\\
        :le=^H:bl=^G:cr=^M:it#8:ho=\\E[H:nw=\\EE:ta=^I:is=\\E)0:\\
        :li#57:co#212:am:xn:xv:LP:sr=\\EM:al=\\E[L:AL=\\E[%dL:\\
        :cs=\\E[%i%d;%dr:dl=\\E[M:DL=\\E[%dM:dc=\\E[P:DC=\\E[%dP:\\
        :im=\\E[4h:ei=\\E[4l:mi:IC=\\E[%d@:ks=\\E[?1h\\E=:\\
        :ke=\\E[?1l\\E>:vi=\\E[?25l:ve=\\E[34h\\E[?25h:vs=\\E[34l:\\
        :ti=\\E[?1049h:te=\\E[?1049l:us=\\E[4m:ue=\\E[24m:so=\\E[3m:\\
        :se=\\E[23m:mb=\\E[5m:md=\\E[1m:mr=\\E[7m:me=\\E[m:ms:\\
        :Co#8:pa#64:AF=\\E[3%dm:AB=\\E[4%dm:op=\\E[39;49m:AX:\\
        :vb=\\Eg:G0:as=\\E(0:ae=\\E(B:\\
        :ac=\\140\\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\\
        :po=\\E[5i:pf=\\E[4i:Km=\\E[M:k0=\\E[10~:k1=\\EOP:k2=\\EOQ:\\
        :k3=\\EOR:k4=\\EOS:k5=\\E[15~:k6=\\E[17~:k7=\\E[18~:\\
        :k8=\\E[19~:k9=\\E[20~:k;=\\E[21~:F1=\\E[23~:F2=\\E[24~:\\
        :F3=\\E[1;2P:F4=\\E[1;2Q:F5=\\E[1;2R:F6=\\E[1;2S:\\
        :F7=\\E[15;2~:F8=\\E[17;2~:F9=\\E[18;2~:FA=\\E[19;2~:kb=^H:\\
        :K2=\\EOE:kB=\\E[Z:kF=\\E[1;2B:kR=\\E[1;2A:*4=\\E[3;2~:\\
        :*7=\\E[1;2F:#2=\\E[1;2H:#3=\\E[2;2~:#4=\\E[1;2D:%c=\\E[6;2~:\\
        :%e=\\E[5;2~:%i=\\E[1;2C:kh=\\E[1~:@1=\\E[1~:kH=\\E[4~:\\
        :@7=\\E[4~:kN=\\E[6~:kP=\\E[5~:kI=\\E[2~:kD=\\E[3~:ku=\\EOA:\\
        :kd=\\EOB:kr=\\EOC:kl=\\EOD:km:"
declare -x TMPDIR="/var/folders/Ot/Ot3uMpWLF-aFeojPSVbhHU+++TI/-Tmp-/"
declare -x WINDOW="0"
declare -x WINDOWID="8388614"
declare -x X11_PREFS_DOMAIN="org.x.X11"
declare -x __CF_USER_TEXT_ENCODING="0x1F5:0:0"

Remote Machine over SSH

declare -x CVS_RSH="ssh"
declare -x G_BROKEN_FILENAMES="1"
declare -x HISTSIZE="1000"
declare -x INPUTRC="/etc/inputrc"
declare -x LANG="en_US.UTF-8"
declare -x LESSOPEN="|/usr/bin/lesspipe.sh %s"
declare -x LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:"
declare -x OLDPWD
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="10.1.0.110 50262 22"
declare -x SSH_CONNECTION="10.1.0.110 50262 10.1.2.20 22"
declare -x SSH_TTY="/dev/pts/9"
declare -x TERM="xterm"

Remote Machine over SSH w/ screen

declare -x CVS_RSH="ssh"
declare -x G_BROKEN_FILENAMES="1"
declare -x HISTSIZE="1000"
declare -x INPUTRC="/etc/inputrc"
declare -x LANG="en_US.UTF-8"
declare -x LESSOPEN="|/usr/bin/lesspipe.sh %s"
declare -x LS_COLORS="no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:"
declare -x OLDPWD
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="10.1.0.110 50147 22"
declare -x SSH_CONNECTION="10.1.0.110 50147 10.1.2.20 22"
declare -x SSH_TTY="/dev/pts/4"
declare -x TERM="xterm"

Best Answer

For the first and third points, try setting TERM while you're using screen to the same things it is when you're not (or if it's already the same, try setting it to "screen").

Edit:

To have vim exit so it shows the contents of the screen before you started it while running under screen, add altscreen to your ~/.screenrc file.

Edit 2:

To make underlined text show in color add this to your ~/.screenrc file:

attrcolor u "-u R"

The "R" stands for bright red. Lowercase would be normal. "B" is blue, etc.

Edit 3:

To stop the extraneous underlining, add this to your ~/.screenrc file:

attrcolor d -d

The first "d" stands for default. The "-d" means remove the "dim" attribute.

Related Question