Automating my WSL Setup
Tags: productivity, tutorial, ubuntu
Published: 2020-01-31 16:53:57

# Setting up WSL #

A few months ago I got rid of my old laptop that I had dual booted Linux and Windows on and decided to get something much smaller and much more portable. I managed to find an ex-display 13" HP laptop and hey-ho, my portability increased ten-fold. 

### However ###

This tiny-but-mighty bargain has nowhere near enough hard drive space for me to dual boot Linux and I'm too far down the Unix path to even attempt relearning my workflow on Windows.

## In walks WSL to save the day ##
There are so many blog posts about WSL that are based on a way deeper understanding than I have, but the general idea is that it's a Linux OS inside Windows 10 and it means I don't have to dual boot. 

Over the last few months I've used WSL in its various incarnations on both my tiny laptop and my desktop PC, using different terminals, settings, configurations etc. And every time I have to reinstall it or just want a clean slate to work from, I have to try and remember everything I did last time I set it all up.

This is a massive waste of time and I always end up forgetting what I did. I've also stumbled across loads of little bugs, the most recent being that the excellent [spaceship prompt](https://github.com/denysdovhan/spaceship-prompt) that I happily use on my work Mac does not get on well with WSL. For whatever reason (probably already documented [read/write speed issues](https://github.com/microsoft/WSL/issues/4197)) changing directory would take upwards of 7 seconds. 

In an attempt to fix this I ended up reinstalling WSL from scratch and loading in different configurations until I found a solution that worked. But setting this all up on two different computers was a massive pain and I _really_ don't want to have to do this again.

## The answer ##

**Automation.**

Kind of.

I decided to hack together a script that basically automated all the steps I had to take after installing Ubuntu 18 on WSL.

The resulting script and config can be found in a [github repo](https://github.com/buck06191/wsl-setup) along with instructions on how to run it all and the end result can be seen below:
![Picture of the final terminal window](https://dev-to-uploads.s3.amazonaws.com/i/bn2d7qsu11jjb7268ywu.PNG)

I decided to use [`powerlevel10k`](https://github.com/romkatv/powerlevel10k) as it gave me enough functionality without slowing the whole thing down. I'm also using [Windows terminal](https://github.com/microsoft/terminal) with the [FuraCode Mono Nerd Font](https://www.nerdfonts.com/) as I found these gave me the best experience in terms of nice Powerline symbols and readability. 

### Inevitable Problems/Bugs ###

I did have a few problems that I would love someone to solve for me. The main one is that I install `zsh` inside the script, followed by `oh-my-zsh`. After this step `oh-my-zsh` kicks me back out to prompt, requiring me to then run the script again where it can then skip to the following steps and then run through to completion.

It's not a deal breaker but it is annoying.

--------------------
I hope that if anyone else is using WSL and is needing a responsive and easy to run set up that this can help them. 

If you find anything that can be improved or needs fixing, please do raise an issue on Github and I'll give it a look when I get chance.

You can follow me on Twitter at [@itsJoshB](https://twitter.com/itsJoshB) for occasional ramblings about tech and other things.

Thanks for reading!