Cygwin for console users
Posted by: Borszczuk in Computers, Linux, Windows, tags: console, cygwin, howto, Linux, rxvt, setup, shell, WindowsFor those who do not know it yet, Cygwin is free, Linux like environment for Windows that provides substantial API that allows you to build (and then run) linux applications. It does not run Linux native apps out of the box, but for most cases it’s pretty easy to recompile one from its sources. This lets you have and run lot of Linux applications you know and use on your windows box. And that Cygwin is for. While installation of Cygwin is rather simple task, some things shall be "corrected" by hand, to make Cygwin use more comfortable.
Installation is simple: visit cygwin.com website, download setup.exe visual installer application, choose target directory for your setup. It defaults to "C:\cygwin", but it’d also work when you decide to use i.e. "C:\Program Files\cygwin", however I keep default path as it’s then simpler to get there (especially your $HOME directory is also there). Then select "Local Package Directory" which is sort of temporary disk cache for Cygwin installer (I do use: "C:\Documents and Settings\<ME>\Local Settings\Temp" directory). Then click "Proceed" enough times to make it fetch packages list and then install all preselected stuff. You may wish to review what is going to be installed, but it won’t hurt to have it done later when you be more familiar what is ‘core’ for Cygwin and what is not.
Installer adds couple of icons to your Start menu, but it does not add itself. As you will use installer later on to uninstall apps, add new stuff and to upgrade existing packages, I suggest to copy Installer application to Cygwin home (i.e. as C:\cygwin\InstallerSetup.exe) and add its icon to your "Start" menu).
Now, launch "Cygwin Bash Shell" and let it set up your home directory. You probably noticed that by default bash was running using default windows "terminal". This terminal is absolutely of no use for anyone who tends to use console longer than for 1 minute. It does not scale its window well, it’s not configurable, it’s history buffer sucks, its….. So we are going this fixed. Launch Cygwin installer and find "rxvt" package (just "rxvt", no "rxvt-unicode") to install ("View: Full" mode would help). Switch its status from "Skip" to highest version number you can get there and "Proceed" to install it (if you see no "rxvt" package listed restart installer and choose other Cygwin mirror).
Once you got rxvt installed we need to tell Windows that it shall use rxvt instead of command.com. Get into C:\cygwin and create Cygwin-rxvt.bat file with the following content:
@echo off
:_WindowsNT
if "x%MSYSTEM%" == "x" set MSYSTEM=MINGW32
if "%1" == "MSYS" set MSYSTEM=MSYS
if NOT "x%DISPLAY%" == "x" set DISPLAY=
if EXIST bin\nul cd bin
if EXIST rxvt.exe goto startrxvt
if EXIST sh.exe goto startsh
echo Cannot find the rxvt.exe or sh.exe binary -- aborting.
pause
exit 1
rem If you don't want to use rxvt then rename the file rxvt.exe to something
rem else. Then sh.exe will be used instead.
:startrxvt
rem Setup the default colors for rxvt.
if "x%MSYSBGCOLOR%" == "x" set MSYSBGCOLOR=Black
if "x%MSYSFGCOLOR%" == "x" set MSYSFGCOLOR=White
if "x%MINGW32BGCOLOR%" == "x" set MINGW32BGCOLOR=Black
if "x%MINGW32FGCOLOR%" == "x" set MINGW32FGCOLOR=White
if "%MSYSTEM%" == "MSYS" set BGCOLOR=%MSYSBGCOLOR%
if "%MSYSTEM%" == "MSYS" set FGCOLOR=%MSYSFGCOLOR%
if "%MSYSTEM%" == "MINGW32" set BGCOLOR=%MINGW32BGCOLOR%
if "%MSYSTEM%" == "MINGW32" set FGCOLOR=%MINGW32FGCOLOR%
rxvt -backspacekey -sl 5000 -fg %FGCOLOR% -bg %BGCOLOR% -sr -sbt 12
-fn "Lucida Console"-12 -fb "Lucida Console"-12
-tn cygwin -geometry 160x60 -e /bin/bash --login -i
goto EOF
:startsh
bash --login -i
goto EOF
:EOF
Note: text marked in red , HAVE TO be in one line (it’s 3 or more here due to web browser text wrapping but you need to ensure it goes into one, long line), also "-backspace" argument is not a "square" but character with ASCII code BS, so if copy & paste from this site does not work correctly, get the above file here: cygwin-rxvt.zip and unpack to get cygwin-rxvt.bat.
Meaning of all the options we used can be get from "man rxvt", but briefly: 160×60 is initial console geometry (in columns/rows, not pixels) and "Lucida Console" is our default font with 12px size.
Now final step – enter Start menu and RMB over Cygwin Bash Shell icon and do "Create shortcut". Enter its properties and change "Target" from "C:\cygwin\Cygwin.bat" to "C:\cygwin\Cygwin-rxvt.bat. Change shortcut name to "Cygwin rxvt".
Now, choose "Cygwin rxvt" and enjoy console-that-does-not sucks. Enjoy.