Thom Nichols

Thom

Technology is evolution outside the gene pool

A Better Cygwin Console with RXVT

Cygwin 1.7 was just released a few weeks ago, so I thought it would be a good opportunity to share an old trick for making Cygwin's terminal window a little nicer by using RXVT and 'screen.'

RXVT is a console emulator; basically it replaces the 'cmd' executable that displays the native Windows terminal.  You can also specify the font and use screen to get multi-terminal support.  In order to get just RXVT working, here's a batch script to use instead of cygwin.bat:

@echo off

C:
chdir C:\cygwin\bin
rem if NOT "x%DISPLAY%" == "x" set DISPLAY=
rem if "x%FGCOLOR%" == "x" set FGCOLOR=White
rem if "x%BGCOLOR%" == "x" set BGCOLOR=Black

start rxvt -backspacekey ^H -sl 2500 -sr -tn rxvt -geometry 80x25 -font "Bitstream Vera Sans Mono-14" -e /bin/bash --login -i
exit

Note that the character after the -backspacekey is actually the backspace character (^H or \u08).  If you can't type that literal into your batch script, you'll probably have to copy and paste it from a character map (or get a better editor!)

If you want to use Screen (which I recommend) you can directly start it from RXVT to avoid an additional bash instance.  You can also remove the scroll bar when you use screen, since scrolling is handled by keyboard commands similar to *NIX pagers like the less command.  If you're not familiar with screen, here's a tutorial and reference.  Here's the command to invoke cygwin using RXVT and screen:

start rxvt -backspacekey ^H -sl 2500 +sb -tn rxvt -geometry 100x55 -font "Lucida Console-12" -e /usr/bin/screen -a

In this case, Screen determines which shell to start up when invoked.  Finally, a screenshot of the result:  

rxvt-screen.png

One more trick - RXVT's default icon is pretty bland, and I'd much rather use the Cygwin icon.  How to do that?  Enter XNResourceEditor.  You can modify the Windows icon for any executable, and also extract icons that are already embedded in .exe files.  I imported the Cygwin.ico file that comes with their distribution into rxvt.exe -- but remember every time you upgrade Cygwin you'll have to repeat this process.

Not so keen on Screen?

As an alternative to RXVT and screen, you can also use Console2, which is a little more user-friendly, with configuration dialogs and visual tabs for multiple environments.  Console2 is also handy for directly running interactive language interpreters such  as Python and irb.  I actually went overboard to see how useful multiple shells can  be -- and the answer is it can be pretty handy:  

console-tabs.png

All tabs even have their own icon!  Note that not all of these packages came with a .ico file, I had to extract the icons using XNResourceEditor for Python and PowerShell, and I downloaded the Ruby icon.

Category: Cygwin Windows console

(Comments are closed)

3 Comments

  1. avatar Re: A Better Cygwin Console with RXVT Dec. 29, 2009 Thom

    BTW - here's my '.screenrc' file:

    #show red BG, window list, spacer, & system load - time @ right edge
    #caption always "%{= BW} %w %= %l - %c "
    hardstatus alwayslastline "%{= BW} %w - %= | %c"

    #http://edeca.net/site/linux:screen
    #caption always "%{= bb}%{+b w}Screen: %n | %h %=%t %c"
    #hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"

    # Our warning of activity
    activity "Activity in %t(%n)"

    startup_message off

    # advertise hardstatus support to $TERMCAP
    termcapinfo * '' 'hs:ts=\E_:fs=\E\\:ds=\E_\E\\'

    # set every new windows hardstatus line to something descriptive
    defhstatus "screen: ^En (^Et)"

    defscrollback 5000
    shell -/bin/bash
    shelltitle '$ |sh'
  2. Re: A Better Cygwin Console with RXVT Nov. 5, 2010 David

    Have you tried using 'screen' under Console2?  I'm use screen heavily and have been using it with rxvt and Xming but that setup seems like a huge memory hog. I wanted to try using Console2 and screen but 1) the hardstatus bar under screen messes up the display on Console2 as it tries to scroll everytime there's an update. And 2) I can't reattach a detached screen session, haven't found out why yet.

  3. avatar Re: No screen &amp; console2 Nov. 9, 2010 Thom

    Well, my primary goal was simply multiple sessions, which both screen and Console2 achieve...  So there's little reason for me to use both.  I would assume rxvt would use less memory than Console2 since it's much simpler.  If you're concerned about memory you could probably use screen in a plain 'cmd' window.