Configuring MSYS for real work

Posted by pulkomandy on Mon Jul 16 21:18:16 2012  •  Comments (0)  • 

People always request Windows binaries for some of my project, so I'm using a fairly complete MinGW/MSYS setup to get this done. However, the default setup for MSYS is not very efficient and doesn't manage to blend well in a Windows install (which is kind of expected). Here are some tricks to make it behave a bit better.

Bash prompt

An improvement on my existing "exit-status-colored" bash prompt. In Windows the path get long very easily (starting with "/c/Document and Settings/user/My Documents" before you've even got anywhere!). So here's a bash prompt that looks just like the previous one, but truncates the path to the last 4 elements. It's rather useful for other OSes, as well.

function exitstatus {
 if [ "$?" -eq "0" ]


 p=($(echo "\w"))
 if [ $d -lt $e ]; then
 for ((;$e-$b+1; b++)); do
 echo -n "\[\e[01;$COLOR;40m\]\u@\h\[\e[39m\]:\[\e[01;34m\]$P \[\e[0m\e]0;$P\$\a\]\$ "

While you're setting up bashrc and profile, you likely also want to setup $EDITOR, and the usual ll and la aliases (to ls --color).

Terminal emulator

The default setup uses Windows' DOS shell window to run bash. This gets annoyingvery quickly : it is not resizeable and has a lot of other bugs. I tried Console2 for a while but wasn't too happy with it either. The MinGW-provided rxvt seems to work fine. MinTTY looks interesting, but I didn't notice it before I was done with rxvt. Maybe next time...

Anyway, the default settings for rxvt are not too nice. I did some changes to make it a bit nicer and more useful. The first step is to open MSYS.BAT and replace the rxvt start command (start %WD%rxvt ...) with this:

set HOME=/home/USER
start %WD%rxvt -backspacekey ^H -sl 2500 -fn "Lucida Console-11" -fb "Lucida Console-11" -sr -geometry 132x50 -e /bin/sh --login -i

The HOME variable is set so rxvt can find .Xdefaults, and I also changed the font, increased the window size, and removed some color-related options.

Next step is to add a .Xdefaults file in the aformementionned HOME directory. There we'll setup the colors to look a bit nicer. Notice I used the same font for bold and normal text (rxvt bold rendering looks bad). So I set up different colors for bold and non-bold, so I can see all the 16 colors (rxvt could support up to 256, but this is not compiled in the mingw version). Here's my colorscheme.

Rxvt*color0: black
Rxvt*color1: orangered
Rxvt*color2: forestgreen
Rxvt*color3: gold
Rxvt*color4: dodgerblue4
Rxvt*color5: indigo
Rxvt*color6: cyan4
Rxvt*color7: azure3
Rxvt*color8: darkgrey
Rxvt*color9: crimson
Rxvt*color10: darkolivegreen1
Rxvt*color11: darkorange
Rxvt*color12: dodgerblue
Rxvt*color13: deeppink
Rxvt*color14: aquamarine
Rxvt*color15: white

More apps

Now install vim and svn (tortoiseSVN provides svn command-line client as an option in the installer), add them to bash path, and you're ready to go.

A little annoyance left : when started from bash, vim will read config in /home/user. When started from anywhere else, it will read in document and settings/user instead. So you have to copy your vimrc and vimfiles in both places.

Leave a comment

Name: Mail: