[UPDATE July 2022: I switched to using MobaXterm which does the job just fine. I don’t like that it is not free/open but I do like that it comes with an integrated SSH agent, which makes life a lot easier]
I had been a happy WSL1 user for many years, but after switching laptops I more or less had to upgrade to WSL2. Which is the same thing but not really.
The thing is, WSL2 startup times are annoyingly slow. And I hate slow. Computers have to be fast and snappy.
So after poking around — many blogs and Github issues — I decided to ditch WSL and move on.
So I entered the world of terminal emulators and unixy environments, which can be overwhelmingly confusing at times.
Windows Terminal
First I settled on Windows Terminal as a terminal emulator. I already starting using this for WSL (which comes default with MinTTY).
MinTTY is used *a lot* and many tools are actually MinTTY under the hood. Cygwin also comes with MinTTY by default. And MinTTY is pretty good, however: it has no tabs.
Windows Terminal is the only terminal emulator I found (on Windows) that does tabs decently! The only other ones I found were ConEmu, but it feels a bit less snappy, and cmder (which uses ConEmu so it has the same problem).
Once you have tabs, you don’t want to go back.
Windows Terminal is a native Windows binary, so that might explain that snappy feel.
So Windows Terminal it is.
But now, how do I get that Linux feel on Windows! WSL1 was pretty perfect, an almost native feeling Linux environment.
There are many alternatives and emulation option (like running VirtualBox or MinGW et al.) but why not go with good, old, trusty Cygwin solution. Their tagline is enticing:
I knew Cygwin from way back, and I noticed it still hasn’t changed its logical, but somewhat archaic installation procedure.
Cygwin installs itself in a folder with a bunch of recompiled for Windows GPLtools, to create a hierarchy that LOOKS and FEELS like a Linux environment.
Fine, whatever.
As long as I can use, grep, rsync, ssh, wget, vim and awk, right?
And I can. Cygwin makes a whole lot of recompiled GNU tools available for Windows — including the above.
However a basic Cygwin installation is pretty minimalistic, so I had to run the installer a few times to get all the software packages I needed (like ssh, vim and wget they are not installed by default). This makes Cygwin a bit different: you can — and usually have to — run the installer a few times to get everything you need.
Next I added Cygwin to my Windows Terminal and made it the default. And with ‘added’ I mean I made a Windows Terminal profile that starts the bash.exe program that comes with Cygwin and drops me in the Cygin homedir (which is actually a Windows path).
A terminal emulator in itself does nothing except handle input / output, and running a shell program like bash enables you to interact with your files (or OS) by sending input signals trough a terminal emulator and processing its output signals.
Cygwin comes with MinTTY by default (of course): if this had (decent) tabs, I’d probably chuck Windows Terminal.
In Windows Terminal you can click a profile together, which edits a JSON file, but you can also directly edit the JSON if you know what you are doing.
Improvements
I think I really like that Cygwin keeps everything in one folder and doesn’t mess too much with my Windows installation, or path settings and all that. I think (?) it’s just a folder (pretty portable).
Two things though.
Prompt
Cygwin needs a better looking prompt. Well here you go:
export PS1="\u@\h:[\e[1;32m]\w \e[m \D{%T}# "
Try it, you’ll like it. Colors, path, username, time, it has everthing! Put it in your .bash_rc
SSH
I could not figure out why my SSH keys weren’t working when connecting to my server. But when I dropped into verbose mode (ssh -vv) I saw ssh wanted to use keys from C:\Users\Jan van den Berg\.ssh instead of the Cygwin homedir /home/jan/.ssh
I spent waaaaay too much timing thinking why Cygwin would do this, until I noticed the SSH binary I invoked was the default Windows 10 OpenSSH client, which will default to looking in the Windows homedir for ssh keys instead of the Cygwin homedir.
So you have to specifically invoke /bin/ssh (or you can remove the Windows OpenSSH client, or change symlinks, or change paths, whatever works for you).
The lesson is: be aware that Cygwin is just a bunch of Windows executables, and it will therefore also look in your Windows path.
Conclusion
I think I am pretty happy with this setup, mainly because it starts almost instantly! And that was the whole point.