Cygwin, X, ratposoin, screen, rxvt setup



This is my OLD blog. I've copied this post over to my NEW blog at:

http://www.saltycrane.com/blog/2007/09/cygwin-x-ratposoin-screen-rxvt-setup/

You should be redirected in 2 seconds.



Here are my configuration files for my current Cygwin, X, ratpoison, screen, urxvt, bash setup.

General Cygwin and bash
  • I changed filename completion to be case-insensitive since we're on Windows. To do this, see the last line in ~/.bashrc and the last line in ~/.inputrc below.
  • I changed the "/cygdrive" prefix to just "/". To do this, type this command once: "mount -s --change-cygdrive-prefix /"
  • I added aliases to use "grep" and "ls" with color. And I added aliases to start various windows applications. See ~/.bashrc.
urxvt
  • urxvt (rxvt-unicode) is a better alternative to rxvt and xterm. See the ~.Xdefaults file for my urxvt customizations. I chose an anti-aliased font, removed the scrollbar, changed the background to dark blue and the foreground to light yellow, and set the number of saved lines to 8000. (Note, to scroll, hit SHIFT+PGUP or SHIFT+PGDN).
ratpoison and screen
  • GNU Screen is a terminal multiplexer which can be used to manage terminal sessions. Ratpoison is a simple keyboard driven window manager largely modeled after GNU Screen which is used as an alternative to complex window managers such as Gnome or KDE. Most of the ratpoison and screen configuration is copied from Mark Pilgrim. The layering, as I understand it, is: the Windows XP OS runs the Cygwin/X environment which runs the ratpoison window manager which runs the urxvt terminal emulator which runs the screen terminal multiplexer which runs the bash command shell.
Update 5/2/2008: I learned how to paste in urxvt (actually bash). See my post, How to paste in Cygwin bash using CTRL+V.

startxwin.bat (windows batch file)
@echo off
SET DISPLAY=127.0.0.1:0.0
SET CYGWIN_ROOT=\cygwin
SET RUN=%CYGWIN_ROOT%\bin\run -p /usr/X11R6/bin
SET PATH=.;%CYGWIN_ROOT%\bin;%CYGWIN_ROOT%\usr\X11R6\bin;%PATH%
SET XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
SET XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
SET XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
SET XNLSPATH=/usr/X11R6/lib/X11/locale

if not exist %CYGWIN_ROOT%\tmp\.X11-unix\X0 goto CLEANUP-FINISH
attrib -s %CYGWIN_ROOT%\tmp\.X11-unix\X0
del %CYGWIN_ROOT%\tmp\.X11-unix\X0
:CLEANUP-FINISH

if exist %CYGWIN_ROOT%\tmp\.X11-unix rmdir %CYGWIN_ROOT%\tmp\.X11-unix
if "%OS%" == "Windows_NT" goto OS_NT
echo startxwin.bat - Starting on Windows 95/98/Me
goto STARTUP

:OS_NT
echo startxwin.bat - Starting on Windows NT/2000/XP/2003

:STARTUP
%RUN% XWin -rootless -clipboard -silent-dup-error
%RUN% /usr/local/bin/ratpoison
~/.ratpoisonrc
# initial frame and window setup
hsplit
focusright
exec urxvt -e screen -RD

# use Pause as prefix key instead of Ctrl-T
escape Pause

# use global cursor positioning (not per-frame)
warp off

# set appearance of ratpoison status messages and input line
set bgcolor black
set fgcolor grey95
set font -b&h-lucidatypewriter-bold-r-normal-sans-18-180-75-75-m-110-iso8859-1
set inputwidth 1247
set bargravity ne
set barpadding 4 4
msgwait 3

# top-level shortcuts (don't require prefix key)
definekey top C-M-Up focusup
definekey top C-M-Down focusdown
definekey top C-M-Left focusleft
definekey top C-M-Right focusright
~/.Xdefaults
URxvt*background: #000033
URxvt*foreground: #ffffcc
! run "fc-list" for a list of available fonts
URxvt*font: xft:Bitstream Vera Sans Mono:size=12
Urxvt*boldFont: xft:Bitstream Vera Sans Mono:size=12:style=Bold
URxvt*scrollBar: False
URxvt*scrollTtyOutput: False
URxvt*scrollTtyKeypress: True
URxvt*secondaryScroll: True
URxvt*saveLines: 8000
~/.screenrc
shell /usr/bin/bash

# scrollback
defscrollback 8000

# Window numbering starts at 1
bind c screen 1
bind 0 select 10
screen 1

# Create initial windows
screen -t home 1
screen -t myproj 1
screen -t pydev 1
screen -t docs 1
screen -t misc 1

# Set the caption on the bottom line:
# window-list   am/pm
# from http://diveintomark.org/public/2007/03/screenrc
caption always "%{= kw}%-w%{= BW}%n %t%{-}%+w %-= %1` %m/%d/%y %C:%s%a"

# use backtick for prefix key instead of Ctrl-A
escape ``

# use regular audible bell
vbell off

# skip intro
startup_message off

# detach on disconnect
autodetach on
~/.bashrc
# prompt 
# see http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
export PS1="\n\e[31;1m\w\n\e[0m\$ "

# cygwin aliases
alias where='type -a'
alias grep='grep --color'
alias ls='ls --color=auto'
alias la='ls -dlAog --time-style="+%Y %m/%d %H:%M" .*; ls -Xlog --time-style="+%Y %m/%d %H:%M"'
alias ll='ls -Xlog --hide "*~" --hide "*.bak" --hide "*.orig" --time-style="+%Y %m/%d %H:%M"'
alias dir='ll'
alias ec='emacsclient -n '

# directory aliases
alias home='cd ~'
alias progfiles='cd /c/Program\ Files'
alias incoming='cd ~/incoming'

# windows aliases
alias firefox='/c/Program\ Files/Mozilla\ Firefox/firefox.exe &'
alias eclipse='/c/Programs/eclipse3.3/eclipse.exe -vmargs -Xms192m -Xmx192m &'
alias serena='/c/Program\ Files/Serena/vm/win32/bin/pvcsvmnt.exe &'
alias kdiff='/c/Program\ Files/KDiff3/kdiff3'
alias explorer='/c/windows/explorer /e /root,'
alias outlook='/c/Program\ Files/Microsoft\ Office/OFFICE11/OUTLOOK.EXE &'
alias taskmgr='/c/windows/system32/taskmgr.exe &'
alias word='/c/Program\ Files/Microsoft\ Office/OFFICE11/WINWORD.EXE '
alias excel='/c/Program\ Files/Microsoft\ Office/OFFICE11/EXCEL.EXE '
alias powerpoint='/c/Program\ Files/Microsoft\ Office/OFFICE11/POWERPNT.EXE '
alias acrobat='/c/Program\ Files/Adobe/Acrobat/Acrobat.exe '

# Get bash filename completion to be case insensitive - there is also a line in .inputrc
shopt -s nocaseglob
~/.inputrc
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char

# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line

# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line

# Get bash filename completion to be case insensitive - see also .bashrc
set completion-ignore-case on

3 comments:

andrew said...

Very nice! Thanks for this. Great blog, very useful.

Anonymous said...

I use cygwin and just shifted to rxvt from using the windows command line (DOS BOX).

1. is there a way to map ctrl-c and ctrl-v to directly copy paste from other applications ? the mouse operation for copy and shift-insert for paste is painful

2. after shiting, file name expansion using tabs in bash shell stopped. any pointers ?

thanks for your help.

sofeng said...

anonymous:
1. i would also like to find a better way of copying and pasting from/to (u)rxvt. currently, i use the mouse: selecting to copy and middle mouse button to paste. mark pilgrim pipes to /tmp/1 which he has bookmarked to copy/paste to firefox. i'm not sure i exactly understand this method. i wouldn't think it could be used for arbitrary text. you might be able to play with xmodmap to get the desired results. if i figure anything out, i will post it.

2. you might not be running a bash shell inside rxvt. from the rxvt man page, rxvt runs "the program specified by the SHELL environment variable or, failing that, sh". to make sure you run bash, use: "rxvt -e bash"

About

This is my *OLD* blog. I've copied all of my posts and comments over to my NEW blog at:

http://www.saltycrane.com/blog/.

Please go there for my updated posts. I will leave this blog up for a short time, but eventually plan to delete it. Thanks for reading.