5

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"
Brian
  • 389
  • 4
  • 10

2 Answers2

4

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.

Dennis Williamson
  • 106,229
  • 19
  • 167
  • 187
  • I tried changing my term to screen, xterm, or not setting it at all. All with the same result. I will post my current screenrc. Thanks for help. – Brian Sep 16 '10 at 20:25
  • @Brian: Your shell startup file (e.g. `~/.bashrc`) could be overwriting `TERM`. Do an `echo TERM` while running `screen` and while not and see if it is what you expect. – Dennis Williamson Sep 16 '10 at 21:19
  • Doesn't appear to be. If I use xterm or screen in my screenrc, that is what it is set to once I'm running screen. Before I run screen, my TERM is set to xterm. – Brian Sep 17 '10 at 13:26
  • @Brian: See my edit. – Dennis Williamson Sep 17 '10 at 13:54
  • This doesn't seem to be working either. Not sure if it matters, but the underlined text is seen when I am ssh'ed to another machine. Thanks for all your help. – Brian Sep 20 '10 at 12:27
  • @Then it's the `TERM`, etc., on *that* machine that's affecting things. – Dennis Williamson Sep 20 '10 at 13:17
  • When I was comparing the TERM setting, I was doing it using that ssh connection. If I ssh without using screen to that server and run a build command, the output is in green and blue colors but not underlined. If I do the exact same thing after running screen on my local machine, the colors are still there but everything is underlined. – Brian Sep 20 '10 at 20:42
  • @Brian: perhaps it be helpful to add a grid to your question showing Machine A, Machine A w/ screen, Machine B via ssh and Machine B local (if you can) on one axis and `TERM` and the output of `tput setaf 4 | hexdump -C` (just the printable characters and placeholders - it will look something like ".[34m" or ".[38;5;4m" - use `od -c` if you don't have `hexdump`) on the other. Are both blue and green underlined? Are you also getting the color when they're underlined? What about other colors (try red: `tput setaf 1; echo hello; tput sgr0`)? – Dennis Williamson Sep 20 '10 at 21:21
  • The tput command had the same output on the remote machine regardless of screen being used - |.[34m| . Both the blue and green text are underlined and they remain that color when underlined. When I use the red tput command, it outputs the red word Hello, not underlined. This happens the same regardless of screen being used. – Brian Sep 21 '10 at 12:53
  • @Brian: If you pipe your script through `hexdump` do you get `^[[4m` (escape lbracket 4 m) anywhere in the output? That's `tput smul` which turns on underlining. Also, look for 1, 5 or 7 in place of the 4 (bold, blink and smso (standout)). Because it seems odd to me that *both* blue and green are underlined, but manually doing red isn't. Also try the red test as above, but with blue (4) and see if doing it manually makes it underlined. – Dennis Williamson Sep 21 '10 at 14:48
  • When you say "your script", do you mean the export statement that generates the declare statements. If so, I ran it through hexdump -C and it didn't see anything with ^[[. – Brian Sep 21 '10 at 18:07
  • I think I figured out by what you meant with my script. I am running some phing commands and it is that output that I'm having trouble with. I went back and ran phing through hexdump and did not see any of those characters. I found this link ( http://phing.info/trac/ticket/222 ). This could just be an issue between phing and screen. Not sure what exactly, but someone mentions it in the link. Thanks again for all your help. – Brian Sep 21 '10 at 18:16
  • 1
    @Brian: Compare your phing `defaults.properties` to [here](http://www.phing.info/trac/browser/trunk/classes/phing/listener/defaults.properties). Also see: [this](http://www.phing.info/trac/changeset/436). I was able to repro your problem. Using the following command in `screen` I got underlines. Without screen: no underlines. `echo -e "\e[2;32mHello\e[m"` Change the first two to a zero and the underline goes away. Edit `classes/phing/listener/AnsiColorLogger.php` and in the `__construct()` function change `DIM` to `NORMAL` and you should be OK. Or update to 2.4 or later. What ver. do you have? – Dennis Williamson Sep 21 '10 at 19:56
  • Wow, lots of good info Dennis. Unfortunately I may not be able to fix this. The reason why I ssh to this server is that it is our webserver at work and we each have our own setup on this server for development. So we only have one copy of phing. We are currently running version 2.32. Its doubtful the admin will adjust the file for the two screen users that we have here. I really appreciate all your help. I learned a ton through this whole process. Thanks again. – Brian Sep 22 '10 at 12:19
  • 1
    @Brian: See edit 3. I think we may have the underlines beaten! – Dennis Williamson Sep 25 '10 at 04:06
  • Awesome! Thanks for the help on this. I'd give you more votes if I could. Thanks again for the help. I've learned a lot through this whole process. – Brian Oct 14 '10 at 12:27
1

Here's a partial answer.

  • Scrollback - To scroll back within a screen window, type Ctrl-A [. You can then use Vim-style cursor-movement and scrolling commands to move back through the scroll buffer. Just type <esc> to get out of that mode.
  • Quitting Vim - You already asked that question here. Did those answers not work?
garyjohn
  • 34,610
  • 8
  • 97
  • 89
  • Thanks for pointing me back to that question. I've been all over the place and forgot that I asked it. That did fix the issue with quiting vim. About the scrollback - I use Ctrl-A [ a lot. I guess I never tried to use it when I was scrolling with the mouse. I'll have to make sure I always scroll with the keyboard. Thanks. – Brian Sep 16 '10 at 20:24