Making Cygwin portable

One of the very packages I always install when I have to work with Windows is Cygwin. Being able to use my beloved GNU tools really makes things easier. Often I don’t have the option to install it. I grieved a little bit about the fact that some problems could be solved with just 2 commands that were — of course — missing from Windows’ horrendous command prompt. So I snooped around and built the following batch that’ll start a full-blown Cygwin session from i.e. portable harddisk:

@echo off set PATH=%CD%bin;%CD%sbin;%CD%usrsbin;%PATH set HOME=%CD%homePortable mount -bfu %CD%/ / mount -bfu %CD%bin /usr/bin mount -bfu %CD%lib /usr/lib cd %HOME% bash ----login -i

Easy, huh? All you have to do to make it work is renaming your /home/Username to /home/Portable (or simply adjust the setting in the batch). Pretty neat stuff.