I've been a long time Linux user... and because of that I've gotten used to having certain shell functionality on all of the computers I work on. That essentially means finding a usable solution that works on Windows.

READ ME FIRST

!!! 2021 UPDATE !!! If you're on Windows 10, then I recommend you use the Windows Subsystem for Linux for all of your coding and automation needs. I've written an article on how to set up WSL together with Windows Terminal, Docker Desktop, and VSCode.

Making the most of what we've got

Some people run Ubuntu in a VM on their Windows machine but I find that unwieldy (albeit very good in terms of functionality) and most of the time just slow - so many corporate laptops still have only 4G of RAM (and some of them don't even run a 64-bit OS!).

So what's left then? Running stuff natively on Windows! This is what Cygwin does and it works quite well. It has suffered in the past from having a backward terminal (it was using good old command prompt) but no more.

Nowadays, it uses mintty, which is an Xterm-compatible terminal emulator with code based on PuTTY.

It still suffers from the same major downside PuTTY has - lack of a tabbed interface. I can hear some of you sighing as you read this. I do love and use PuTTY for a number of things and I've put in a small chapter at the end of this article about it (colors, tabbed interface).

Cygwin and friends

First reaction when starting a vanilla Cygwin will be one of horror... the font is small and ugly, colors are basic and there are no tabs. No good. Let's fix all of that.

Diagram

Colors and fonts

The default ones are OK as far as colors go, but they're not that pleasing for the human eye.

The output you see below is using a script from The BASH HowTo (it's also in the colortest package on Linux distros).

Diagram

The colors I'm mainly using are from the Solarized palette - check the link for more on the theory behind the theme. You can get it for a big variety of editors, shells, terminals and if you google it, many people have adapted it to their favorite software. Get the mintty theme here.

What I'm using is the dark Solarized theme with one change: my eyes don't agree with the dark blue background so I've switched it to pure black.

You'll notice the font is Consolas, which is my favorite monospaced font on Windows. I also like Inconsolata, but I found it doesn't render as well in Windows as it does in Linux.

Put the following in your Cygwin home in .minttyrc:

BoldAsFont=yes
RightClickAction=paste
Font=Consolas
FontHeight=12
Term=xterm-256color
BoldAsColour=yes

Black=0,0,0
Red=220,50,47
Green=133,153,0
Yellow=181,137,0
Blue=38,139,210
Magenta=211,54,130
Cyan=42,161,152
White=238,232,213
BoldBlack=0,43,54
BoldRed=203,75,22
BoldGreen=88,110,117
BoldYellow=101,123,131
BoldBlue=131,148,150
BoldMagenta=108,113,196
BoldCyan=147,161,161
BoldWhite=253,246,227
ForegroundColour=238,232,213
BackgroundColour=0,0,0
CursorColour=133,153,0

Restart the Cygwin console and behold the result:

Diagram

Better, but there's still a bit of work to do.

Tweaking the shell

All the colors displayed in the console will be much easier on the eyes now. But ls needs a gentle shove in the right direction and that's done through the dircolors utility. This changes how it colorizes output based on file types.

To enable functionality, get the dircolors configuration file from here and save it in ~/.dircolors.

To make it work, just add the following to ~/.bashrc so it gets applied each time you start your shell:

alias ls='ls --color=auto'
eval `dircolors /home/csirbu/.dircolors`

And this is what you get when you run a ls -A:

Diagram

Oh yes, much better. Some more output from a git log command on the mintty-colors-solarized repo.

Diagram

Adding the final touch, the tabs

ConEmu is a console emulator with tabs. You can plug into it quite a few windows application actually, which is pretty cool.

All you have to do is run C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -. The app is ridiculously configurable but I won't go into all of that. To switch between tabs, use Winkey+Tab (you need to enable it in settings) or Winkey+1/2/3....

And we're done! The terminal looks good, it's colorized and tabbed. What more could you want? To not have to use Windows at all.

Diagram

PuTTY, you shall not be forgotten

So you're not interested in running Cygwin but you'd like to have the same good looks and tabs for your PuTTY sessions. Go no further!

First of all, get your Solarized colors from here.

Follow the instructions on the page on how to apply the registry values to your profile. If you want to get the same setup with a pitch-black background instead of the blue one, edit the file and change to "Colour2"="0,0,0".

Change the font to Consolas while you're at it.

That's all, but remember that PuTTY's sessions are remote, so if the remote shell/device you're connecting to doesn't colorize its output, you won't see much difference!

To get PuTTY to have tabs, you have two options (maybe more, but most others are buggy and old):

  1. Use ConEmu as above, only difference is that the command you run is putty.exe. The benefit is that you can mix'n'match sessions in the same window.
  2. Use MTPutty. I've been using this one for few years now and it's quite OK. It has one awesome feature: if you have standalone PuTTY windows (such as those that pop-up from GNS3) it can grab them and incorporate them as tabs without them feeling a thing. It's painless, I swear!

Diagram

The end

Hopefully this has been of some use to all of you stuck with Windows - it's always nice to make your life a bit sweeter if you can.

Some of this configuration I manage with git and there's more about that in a future post, as well as how to customize gnome-terminal to get the same result.

And, as always, thanks for reading.


Any comments? Contact me via Mastodon or e-mail.


Share & Subscribe!