Table of contents
- Install and configure Windows Sub-system for Linux (WSL)
- Install and configure Docker for Windows
- Install and configure Windows Terminal
- Install and configure zsh, Docker and others in WSL.
- Setup Python in WSL
- Install and configure Visual Studio Code
In the last few months, I’ve decided to switch my home computer from a Mac to a PC. The reasoning behind it was pretty simple: I wanted to game a little more and most of the games I like just work better on Windows. That being said, the geek in me still wants to do some development sometimes and play with technologies that are more suited for Linux and for *nix based OSes.
That being said, on that PC, I’ve had a dual-boot with Linux installed but I was wondering what the options were on Windows 10 these days.
Install and configure Windows Sub-system for Linux (WSL)
This is well known stuff and there’s a bunch of well made articles about it. Personally, I’ve followed Microsoft’s documentation here. At the time of writing this, I’m still waiting for WSL2 to come out of development. If rumors are right, this should happen in May 2020.
I’ll document the steps I took and some of the tweaks I made to have it work for my setup.
- In powershell as administrator
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
-
Reboot the system when this step finishes and prompted.
-
Install your favorite distribution from the Microsoft store. Personnally, I’ve used Debian. Instructions will be similar as Ubuntu.
-
Initialize your distro as explained here.
-
Make sure the distro is up to date.
sudo apt update && sudo apt upgrade
- Create a WSL configuration that will make it compatible with Docker and development. This will switch the mounts of the Windows volumes from
/mnt/cto/cand so on.
sudo cat >/etc/wsl.conf <<EOF
# Enable extra metadata options by default
[automount]
enabled = true
root = /
options = "metadata,umask=22,fmask=11"
mountFsTab = false
# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true
EOF
Install and configure Docker for Windows
This part will be expected to change in the future when WSL2 comes out. For now, we’ll stick with having Docker in its seperate VM.
Installation instructions are found here. In summary:
-
Download the package from Docker hub and install it.
-
Go to Docker Settings and check the “Expose daemon on tcp://localhost:2375 without TLS” option. Then click on “Apply and restart”.
Install and configure Windows Terminal
On Windows, we need a proper shell. In the free category, the closest I found to a proper terminal on Windows is Windows Terminal. This is a project from Microsoft which is still in preview but for now works quite well. I’ve started to play with it and I’ve only started to customize it to my taste. Here’s what I did:
-
Get the it from the Microsoft Store and install it. This will ensure you get updates.
-
Go to the “Settings” window by pressing
Ctrl-,. -
Change the
defautProfilevalue for the WSLguidvalue. -
Add the
initialColswith a value of180to the main map. -
Add the
initialRowswith a value of40to the main map. -
Add the
initcopyOnSelectialColswith a value oftrueto the main map. -
In the
defaultsmap, add thecolorSchemewith the value"One Half Dark"and thefontFaceattribute to"Operator Mono".
You should end up with a settings JSON that looks like this:
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
"initialCols": 180,
"initialRows": 40,
"copyOnSelect": true,
"profiles":
{
"defaults":
{
"padding": "10, 10, 10, 10",
"fontFace": "Operator Mono",
"colorScheme": "One Half Dark"
},
"list":
[
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
"hidden": false,
"name": "Debian",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore"
}
]
},
"schemes": [],
"keybindings": []
}
Install and configure zsh, Docker and others in WSL.
I’m starting to get used to zsh since it’s now the new default shell on MacOS so I’ll set it up and experiment on this setup.
-
Start a Windows Terminal.
- Install zsh, direnv and pre-requisites to Oh My zsh.
sudo apt-get update && sudo apt-get install zsh curl wget git direnv - Install via
curlsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - Edit your
~/.zshrcand setup your preferences.vi ~/.zshrcPersonnaly, I’ve setup the following options
ZSH_THEME="maran" CASE_SENSITIVE="true" plugins=(git debian)In the
User configurationsection, I did the following:export PATH=$HOME/bin:$HOME/.local/bin:$PATH # Docker engine export DOCKER_HOST=tcp://127.0.0.1:2375 # AWS Variables source $HOME/.aws/env.sh # Add an SSH agent. eval $(ssh-agent) > /dev/null # Hook up direnv eval "$(direnv hook zsh)" # Ruby Crap # Install Ruby Gems to ~/gems export GEM_HOME="$HOME/gems" export PATH="$HOME/gems/bin:$PATH"This will:
- Add the local bin to the path. Also if you do a
mkdir -p $HOME/bin, you can put binaries in there. - Set
DOCKER_HOSTto use the TCP socket we opened previously. - Create an SSH agent with your local keys.
- Enable
direnv. - Since I’m using Jekyll for this blog. Install the Ruby stuff.
mkdir -p $HOME/gemswould help.
- Add the local bin to the path. Also if you do a
-
Exit and restart Windows Terminal and see your changes.
-
Install Docker in the WSL Debian. We will follow instructions in here
- Install pre-requisites
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common - Add the GPG key.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - - Add the repository
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable" - Install the packages.
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io - Add your user to the
dockergroup.sudo usermod -aG docker $USER - Test docker
docker run hello-world
- Install pre-requisites
Setup Python in WSL
- Install Python 3.
sudo apt-get update && sudo apt-get install build-essential python3.7 python3.7-dev python3-pip - Setup links for
pythonandpipsudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1 sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 - Update
pipsudo pip install --upgrade pip - Install
pipenvpip install --user pipenv - See that
pipenvis working properly.pipenv --version
Install and configure Visual Studio Code
The first IDE I’m planning on testing is Visual Studio Code. It has a nice integration with WSL that’s free. Here’s how to install and do a basic configuration for it:
-
Download Visual Studio Code.
-
Follow the setup instructions here.
-
Install the remote components by follow the instructions here.
-
Since I’m going to follow the Python instructions.
-
We can now issue
code .while in a directory in Windows Terminal and this will pop-up Visual Studio Code in WSL.
That’s all folks!
Return to Fort Kickass.