Saturday, 5 June 2010

Recipe: A decent terminal emulator for Windows

After having been spoilt by the luxury of a using a proper terminal daily for several years I am now forced back into the world of Windows, and cmd.exe or the abomination knows as Windows Console. I'm not sure how the team that wrote cmd.exe/console.exe could actually continue to release the application in good faith (no auto-select by default, then when you do enable it all you get is block select - seriously, wtf?), but anyway, it's not worth pointing out its many deficiences when time is better spent getting a superior alternative set up.

Ingredients:
  • Cygwin, for unix commands in windows (ls, ps, grep, sed, awk, xargs, find, ssh, wget, cat, less, ...) along with your flavour of competent shell (e.g. bash, zsh, etc).
  • puttycyg, for the terminal emulator itself. This is a patch over regular PuTTY that provides an additional connection option of a loopback interface ("Cygterm") to a local cygwin installation. So you get a decent configureable terminal in PuTTY, useable not only for remote connections but as a local terminal emulator for your favourite shell on your local Windows machine.
  • Optionally (but highly recommended), PuTTY Connection Manager (puttycm) for a pretty decent multi-tab wrapper around all your PuTTY instances, along with configureable keyboard shortcuts for creating new tabs/sessions and navigating between sessions (no more shift?-alt-tab/taskbar clutter nonsense).
  • Another optional is some proper fonts (i.e. not Courier *), for example: Liberation, Bitstream Vera, Inconsolata, Proggy, or any number of other high-quality programmer fonts that double up as decent terminal fonts. As a previous fan of Bitstream Vera Sans, after having worked in Windows for about a month now and discovering Consolas as a default-installed font of Office 2007, this has now become my primary choice and I would highly recommend it to others going forward. For some reason Microsoft continue to do pretty well in secondary areas, e.g. hardware/typography but poorly in their primary software capacity (hmm perhaps they're not too dissimilar to Apple after all -- or should that comparison be the other way round?).

Method:
  1. Install all the various applications and fonts you wish, and configure your PuTTY sessions as normal (Puttycyg will also pick up any preexisting PuTTY sessions you had created however). In order to create a new local Cygwin interface, simply create a new session with "Connection type" set to the (newly-available) option of "Cygterm" and specify the "Host Name/IP address" as a single dash (-) which instructs puttycyg to use your default shell.
  2. If working with more than one Cygwin installation the only consideration you'll need to have when using puttycyg is you'll need to start it in the working directory of the /cygwin/bin/ installation you want to use - so any shortcuts you create for the terminal be sure to modify the "working directory" accordingly (puttycyg does include a cygwin auto-detection method however which should be sufficient for single cygwin installations).
  3. You may also want to auto-load your local cygwin session in your shortcut (e.g. for a single-click terminal launch, or easy access via a launcher such as Launchy), in which case you simply need to add "-load [cygterm-session-name]" to your shortcut's target command line. 
  4. If using zsh and Windows 7/Vista you may experience some irritating errors when starting the shell or executing commands; they are usuall some variety of "fatal error - unable to remap ...\zsh\*.dll to same address as parent(0x...)". There is thankfully a simple solution to this:
  • ensure you have the "rebase" package installed in your cygwin instance
  • execute "${CYGWIN_HOME}/bin/ash.exe"
  • $ rebaseall
  • Relaunch your Cygwin instances.
As an added bonus, the following are RGB listings for the excellent "Dark Pastels" colour scheme that Konsole provides out of the box that you can use in your PuTTY sessions (also cmd.exe if you so wish) for even better looking terminals:

Colour                      RGB Values

Default Foreground          R:220, G:220, B:205
Default Bold Foreground     R:220, G:220, B:205

Default Background          R:44, G:44, B:44
Default Bold Background     R:44, G:44, B:44

ANSI Black                  R:63, G:63, B:63
ANSI Black Bold             R:112, G:144, B:128

ANSI Red                    R:112, G:80, B:80
ANSI Red Bold               R:220, G:163, B:163

ANSI Green                  R:96, G:180, B:138
ANSI Green Bold             R:114, G:213, B:162

ANSI Yellow                 R:223, G:175, B:143
ANSI Yellow Bold            R:240, G:223, B:175

ANSI Blue                   R:154, G:185, B:215
ANSI Blue Bold              R:148, G:192, B:243

ANSI Magenta                R:220, G:140, B:196
ANSI Magenta Bold           R:236, G:147, B:213

ANSI Cyan                   R:140, G:209, B:211
ANSI Cyan Bold              R:147, G:225, B:227

ANSI White                  R:220, G:220, B:205
ANSI White Bold             R:255, G:255, B:255

So, that's my recipe on how to get a decent local terminal emulator + shell set up in Windows. Please leave a comment with suggestions for alternatives or improvements if you have any; while the above is a significant improvement over the default cmd.exe behaviour it's still a way off a comparable Linux setup these days.

4 comments:

Bruce Cran said...

I've been using Tera Term for a few years now in preference to PuTTY for serial and ssh connections because it's simpler to setup and I think its terminal emulator may be better - but it also installs a CygTerm link which lets you use it for local sessions too. I believe one feature it has that PuTTY doesn't is that it has clickable URLs.

It seems the old site which hasn't been updated since 1998 still ranks high in Google. The new Tera Term can be found at http://ttssh2.sourceforge.jp/ .

mathew.thomas said...

I've been using http://code.google.com/p/mintty/ which comes as part of the cygwin packages.

Windows 7 Key said...

It is wonderful right here. good research. I've been searched this kind of information for quite a while. thanks
windows 7 professional key

Kshitij Mehta said...

I have been looking for the dark pastels RGB values for putty since some time. Thanks for your post.