Cygwin Setup

A decent Cygwin setup with rxvt and bash.


Cygwin is an environment which provides common unix/linux functionality (libraries, tools, compile, etc., almost everything) on a windows host system. It is a must have for windows power users. This page describes the setup I use for Cygwin on a laptop running Windoze XP Professional. Several modifications to the default configuration along with a few custom scripts are provided for download and use. Pointers to additional must have tools for power users, especially such who usually use Linux or similar, are listed at the end of the article.


A rxvt in native Windoze!

Installation & Configuration

Download & Installation

Cygwin can be downloaded from You only need setup.exe to bootstrap. It will let you choose a mirror to download the software and installation and scratch directories. Cygwin is made of various packages containing individual programs or collections of programs. There are essential packages such as bash, textutils, emacs or rxvt and less often used ones in different categories. The default selection of packages is probably good to start with. The installation program (setup.exe) can be used to install, update or uninstall individual packages at any time. See the excellent page at (or alternatively similar pages at or at for details and screenshots of this process.

The $HOME directory

A Cygwin session has its own root file system (e.g. Cygwin’s / = C:Program Filescygwin). DOS drives can be accessed through e.g. /cygdrive/c. It is also possible to mount DOS paths into the cygwin tree. See the Cygwin manual for details.

By default the home directory (/home/username) is configured to be in C:Program Filescygwinhomeusername (or C:cygwinhome…). It is probably a good idea to change that to your profile path (C:Dokuments and SettingsusernameMy Documents) or a subdirectory within it.

This can be achieved by linking or mounting the chosen directory to /home/username.

cd /home
mv username username.old
ln -s "/cygdrive/c/Documents and Settings/username/My Documents" /home/username.


cd /home
mv username username.old
mount "c:/Documents and Settings/username/My Documents" /home/username

Refer to the Cygwin documentation and FAQ on mounting of directories. The mounts should be persistent by default. Depending on the configuration this step has to be done with administrator privileges.

The rxvt Terminal

Cygwin’s setup.exe, by default, installs a shortcut named Cygwin Bash Shell which opens a terminal window using the windows cmd.exe. But a far better terminal application is available in Cygwin. The package rxvt installs a decent terminal programme running as a native windows application (no X-Server needed!).

The necessary configuration for rxvt is described below.

The following string can be used in a shortcut to start a rxvt terminal window with a bash login shell.

C:ProgrammeCygwinbinrxvt.exe -e /bin/bash --login

Or a batch file containing appropriate commands opens three terminal windos. The geometry flag is used to set the (initial) size and position of the windows.

@echo off
start C:ProgrammeCygwinbinrxvt.exe -geometry 100x41+0+0 -e /bin/bash --login
start C:ProgrammeCygwinbinrxvt.exe -geometry 100x25+0+0 -e /bin/bash --login
start C:ProgrammeCygwinbinrxvt.exe -geometry 100x15+0-25 -e /bin/bash --login

Although rxvt is a native windows application it respects the ~/.Xressources file. The following excerpt from that file is used to set a useable font and a few other settings for rxvt windows.

rxvt.font:            Courier New-18
rxvt.boldFont:        Courier New-18
!rxvt.font:            Lucida Console-18
!rxvt.boldFont:        Lucida Console-18
!rxvt.font:            fixedsys
!rxvt.boldFont:        fixedsys
rxvt.scrollBar:       True
rxvt.visualBell:      True
rxvt.loginShell:      True
rxvt.background:      Black
rxvt.foreground:      White
rxvt.saveLines:       99999
rxvt.cursorColor:     Green
rxvt.scrollBar_right: True

To enable special characters (äöüéà etc.) and certain other settings, the following ~/.inputrc file is used.

# Be 8 bit clean. -> Umlaute, see readline(3)
set input-meta on
set output-meta on
set convert-meta off

# command line scrolling
set horizontal-scroll-mode on

"C-v": paste-from-clipboard
"e[3~": delete-char
# this is actually equivalent to "C-?": delete-char


The following command works with a postscript printer. See also the PRINTER variable in .bashrc. Adjust the host and printer names.

lpr -d '\hostnameprintername'

It is possible to create a virtual Postscript printer in Windows using Ghostscript. I didn’t test this but it looks promising. I would probably use the Adobe Generic PS driver.

GCC and Makefiles

In Cygwin gcc -o hello_world hellow_world.c produces the binary hello_world.exe while the same command in Linux produces the binary file hello_world. This is a problem when the same Makefile sould work in Cygwin and Linux. I avoid it as follows (credits go to das U-Boot project).

HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | sed -e 's/(cygwin).*/cygwin/')

ifeq ($(HOSTOS),cygwin)

all: hello_world.$(SFX)

hello_world$(SFX): hello_world.c
        $(CC) hello_world.c -o hello_world$(SFX)

Bash Configuration

The ~/.bash_profile file only contains one command to load the ~/.bashrc file.

source ~/.bashrc

The ~/.bashrc file is parsed and executed by bash on startup. The LANG and LC_ALL variables should be adjusted to your locale or commented out to select the default (C, English).

# Set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then

alias less='less -r'
alias rm='rm -i'
alias ll='ls -l --color=auto'
alias la='ls -a --color=auto'
alias lla='ls -la --color=auto'
alias l='ls -F --color=auto'
alias ls='ls --color=auto'
alias mc='mc -a'

# language, i18n..
export LANG=de_CH
export LC_ALL=de_CH

case $TERM in
	PS2="> "
	  [[ "${#pcpwd}" -gt 25 ]] && pcpwd="..${pcpwd: -25}"
	  echo -ne "�33]0;${USER}@${HOSTNAME} ${PWD/$HOME/~}�07"
	  green="�33[32m"; orange="�33[33m"; cyan="�33[36m"; off="�33[m";
	  PS1="$greenu$orange@$greenh $cyan${pcpwd}$orange $ $off"
	PS1="u@h w $ "
	PS2="> "

export RSYNC_RSH="ssh -x"
export CFLAGS="-march=i686 -O2"
export LDFLAGS="-L/usr/local/lib"
export OUTPUT_CHARSET=latin1

# adjust the host and printer names
export PRINTER='\hostnameprintername'

umask 0027


In order to make cursor keys work in vim use this command (thanks to Robin Bowes). It furthermore enables nice colours in vim and possibly other features.

cp /usr/share/vim/vim71/vimrc_example.vim ~/.vimrc


Cygwin is the alternative for a native Linux system to me. Since I am bound to several windows programmes, installing Linux is not an option. Using Cygwin brings most of the essential Linux funtionality (bash, texttools, GCC, The Holy GNU Emacs, gawk, etc.) to the windows desktop. For me, that is the solution. For example I develop data processing programmes on the windows laptop using The One True Editor and GCC under Cygwin. The calculation itself can then be carried out on faster and bigger Linux systems. The only step necessary to make that happen, is compiling and linking against the Linux host.


There are certain issues which I have not been able to resolve so far. Any comment or help on that is highly appreciated.

START C:ProgrammeXmingXming.exe -xkbvariant ch -xkbmodel pc105 -clipboard -multiwindow
C:ProgrammeXmingsetxkbmap.exe -display :0 ch

Update: This works as well (in a shortcut leave out the start "foo" part):

start "foo" C:Program filesXmingXming.exe :0 -xkblayout ch -clipboard -multiwindow

Hacks for the Power User

Diagnostics (draft)