Development

WSL2: Roll Your Own

I have always been fond of my VMs to isolate my experiments form my main OS. For a long time it was all about using VirtualBox for running VMs, Vagrant for provisioning them and Packer for creating my own custom images. Then WSL came along, and while lightweight, it never really felt as fully featured as I wanted it to be. Over the last few years, however, Microsoft have come a long way and now there is really no need to manage VMs yourself unless you are doing something very exotic. If fact the whole WSL experience is so smooth that it is indistinguishable from pure magic. This never sits well with the control freak in me. šŸ¤£ This post is a summary of my approach to rolling my own WSL environment and will cover topics like using custom Linux images, managing multiple environments, and tweaking more advanced WSL settings.

PowerShell Measure-Command

Recently I was putting together some VM provisioning scripts, was running and re-running these as a part of testing and wanted to measure how long it takes for some of these scripts to run. PowerShell one-liner to the rescue!

Measure-Command {Start-Sleep -s 10; Write-Output "Done!" | Out-Host}

This snippet consists of three parts. Measure-Command {} which is the bit that does the measuring. Start-Sleep -s 10; Write-Output "Done!" is the command that I’m executing - sleeps for 10 seconds and then prints out “Done!”. Finally, output from the executed command is redirected to the command line like so | Out-Host.

Setting up Git and GitFlow

On those rare occasions when I get a chance to code I tend to work on Ubuntu based virtual environments - VirtualBox VMs and more recently WSL. It is also pretty much a given that I’d need to interact with different Git hosting services like GutHub and BitBucket, and it usually takes quite a bit of tinkering to get everything set up and working smoothly with all the various accounts. These are my steps to to get the Git and GitFlow installed and configured in a jiffy. šŸš€