Set up your Windows system with WSL so that you can start developing right away and the most important tools are installed.
Of course, it is always individual which tools are needed and what to configure. So what I have described fits best for me and the most important things are included. That does not mean that this must fit for you exactly this way and that everything works. Just think about every step a little bit, make modifications if necessary and then it should work for you, so that you have a cool basic setup for development as well. Have fun! 😊
Table of content:
- Windows Clean-Up
- Windows Development Tools
- Windows Utilities
- WSL 2 Activation
- WSL 2 Setup
- WSL 2 Development
- WSL 1 Tips & Tricks
Use powershell and open it as administrator.
Then navigate to your home folder or to any preferred working directory.
cd ~
To get rid of the whole built-in bulk as fast and easy as possible the Windows 10 Debloater is recommended.
Invoke-WebRequest -Uri "https://github.com/Sycnex/Windows10Debloater/archive/master.zip" -OutFile "
Windows10Debloater.zip"
Expand-Archive -LiteralPath 'Windows10Debloater.zip'
rm Windows10Debloater.zip
Now you can run the project from the folder.
Then you can simply activate the dark mode with the following commands.
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0
Then we quickly set the background to a solid grey.
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers" /v BackgroundType /t REG_DWORD /d 1 /f
reg add "HKCU\Control Panel\Desktop" /v WallPaper /t REG_SZ /d "" /f
reg add "HKCU\Control Panel\Colors" /v Background /t REG_SZ /d "73 80 87" /f
TODO: Upgrade to Windows Package Manager
We will install the other things on windows with chocolatey as long as windows does not offer a cool package manager on the command line.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Then we install the following tools for the development.
choco install powertoys vscode docker-desktop kubernetes-helm microsoft-windows-terminal azure-cli terraform vscode-docker -y
choco install powertoys telegram signal discord spotify microsoft-edge enpass.install -y
If you have to use the old WSL because of your windows version you will find some help in this section.
First we have to enable the 'Virtual Machine Platform' and "Windows Subsystem for Linux" optional feature.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
wsl --set-default-version 2
Maybe you have to update your kernel first
To do so execute the following commands or download and install the update via the provided link.
Invoke-WebRequest -Uri "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
.\wsl_update_x64.msi
rm wsl_update_x64.msi
Then we can add a firewall rule for WSL, because this can be really annoying:
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
Ready to download the desired distribution from the Windows Store?
Go for it! 😊
Now you can switch to WSL from your powershell and prepare it for usage.
wsl
TODO Rework
sudo apt-get update \
&& sudo apt-get dist-upgrade -y \
&& sudo apt-get install -qqy \
--fix-missing --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
netbase \
netcat \
libpq-dev \
libssl-dev \
build-essential \
git \
tree \
pandoc
TODO :
sudo apt-get update && sudo apt-get dist-upgrade -y \
&& sudo apt-get install -qqy --fix-missing --no-install-recommends \
texlive-base \
texlive-latex-recommended \
texlive-latex-extra \
texlive-science \
texlive-bibtex-extra \
biber \
latexmk
TODO :
sudo apt-get update && sudo apt-get dist-upgrade -y \
&& sudo apt-get install -qqy --fix-missing --no-install-recommends \
zsh
-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-
git clone \ --depth=1 \ https://github.com/romkatv/powerlevel10k.git \ ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
-
git clone \ https://github.com/marlonrichert/zsh-autocomplete \ ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autocomplete
-
git clone \ https://github.com/zsh-users/zsh-autosuggestions \ ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
-
git clone \ https://github.com/zsh-users/zsh-syntax-highlighting.git \ ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
TODO :
python -m pip install bpytop --upgrade
-
lolcat Because some outputs are very boring...
sudo apt-get install -qqy --fix-missing --no-install-recommends \ lolcat
-
wget https://github.com/Peltoche/lsd/releases/download/0.19.0/lsd_0.19.0_amd64.deb sudo dpkg -i lsd_0.19.0_amd64.deb
-
Aliases:
cat <<EOF alias pip="python3 -m pip" alias update="sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt autoremove -y | lolcat" alias duplicates='find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate' alias perm="stat -c '%A %a %n'" alias dns='sudo sh -c "echo nameserver 1.1.1.1 > /etc/resolv.conf"' alias zugdns='sudo sh -c "echo nameserver 192.168.16.1 > /etc/resolv.conf"' # OEBB W-LAN sucks alias ddrop="docker rm $(docker ps -aq) -f ; docker system prune ; docker volume prune" alias drmi="docker rmi -f $(docker images -f "dangling=true" -q) | lolcat" alias acr="az acr login --name $ACR | lolcat" alias analytics='docker run --name guardia --rm --workdir /workspace -v "$(pwd):/workspace" $ACR.azurecr.io/guardia_cli/3.9/alpine:latest guardia' ### Colorize commands alias ls='ls --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' alias diff='diff --color=auto' alias ip='ip --color=auto' alias pacman='pacman --color=auto' ### LS & TREE alias ll='ls -la' alias la='ls -A' alias l='ls -F' >>
-
Override commands:
command -v lsd > /dev/null && alias ls='lsd --group-dirs first --icon-theme unicode' && \ alias tree='lsd --tree' command -v bpytop > /dev/null && alias top='bpytop'
sudo apt-get update \
&& sudo apt-get dist-upgrade -y \
&& sudo apt-get install -qqy \
--fix-missing --no-install-recommends \
python3 \
python3-distutils \
python3-pip \
python3-setuptools \
python3-dev \
python3-venv
python3 -m pip install -U pip setuptools
mkdir ~/Development
python3 -m venv --prompt '.:|<FANCYNAME>|:.' ~/Development/venv
~/Development/venv/bin/pip install ipykernel notebook jupyter pylint coverage setuptools pre-commit
TODO: Poetry, Azure Artifacts, DevPi, ...
sudo apt-get install nodejs npm -y \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash \
&& export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
exit
Instead of exit
and re-entering the shell you can source
the bashrc/profile/... files changed.
nvm install node
nvm use node
nvm install --lts
nvm use --lts
Get the Azure CLI and add extensions:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az login
az extension add --name azure-devops
Attach Azure DevOps Artifact store:
~/Development/venv/bin/pip install keyring artifacts-keyring
WSL 2 is completely different because of the file system but with the old WSL we can simply map our windows home to our linux home.
sudo mkdir /c && sudo mount --bind /mnt/c /c
sudo vim /etc/wsl.conf
Then add the following content to the WSL conf file:
# Enable extra metadata options by default
[automount]
enabled = true
root = /
options = "metadata,umask=22,fmask=11"
mountFsTab = false
Also change the home directory in /etc/passwd
to
<username>:x:1000:1000:,,,:/c/Users/<username>:/bin/bash
Make sure you enter the correct username!
This step is very important because otherwise you might get some errors which are mainly based on the fact that docker maps all paths from the windows system to the windows path and thus C:\Users\username
becomes /c/Users/username
and in case of /mnt/c
this path from the WSL can not be mapped correctly for windows and subsequently for the docker-VM and consequently volumes can not be included correctly or not at all.
But before we can test this for correct functionality we don't have to tell WSL how to access Docker on the Windows system. We have to tell Linux which executable of Windows it should run. A simple step would be to create an alias from 'docker' to 'docker.exe' which is not a pleasant solution and can lead to problems again. So we just tell wsl which program he should actually execute when calling /usr/bin/docker or /usr/bin/docker-compose.
Therefore we simply tell WSL which program to run:
#!/bin/bash
"/c/Program Files/Docker/Docker/Resources/bin/docker.exe" "$@"
and for docker-compose:
#!/bin/bash
"/c/Program Files/Docker/Docker/Resources/bin/docker-compose.exe" "$@"
and finally also for docker-credential-desktop the same:
#!/bin/bash
"/c/Program Files/Docker/Docker/Resources/bin/docker-credential-desktop.exe" "$@"
Please do not forget to set the correct permissions (chmod +x
) for these scripts.
Now that we have made these changes, we can start the first tests, launch Docker, list and create containers, etc.