Open the Powsershell and run the following command:
wsl --install
We start with adding a update script to Linux, so we can simply update the whole system with one command.
sudo nano /usr/bin/update
The script looks like this:
#!/bin/bash
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y
Just copy the script with the button in the top right corner and paste it into nano. Press CTRL + X and then Y + ENTER. Make the script executable by typing
sudo chmod +x /usr/bin/update
Now you can just use the command update
and type in the admin password.
First install the zsh shell with the command:
sudo apt install zsh -y
Then install ohmyzsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
When asked if you want to with to the zsh shell press Y + ENTER.
First install the node version manager and then install the node lts version.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.zshrc
nvm install --lts
Now enable yarn as an alternative to npm.
corepack enable
Install the newest git version:
sudo apt install git -y
Add your git credentials to your config file:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Add SSH to connect to GitHub without entering the username and password.
ssh-keygen -t ed25519 -C "your_email@example.com"
Enter a file in which to save the key (/home/you/.ssh/algorithm): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Add the ssh key to the ssh agent:
ssh-add ~/.ssh/id_ed25519
Generate a new GPG key pair:
gpg --full-generate-key
Please select what kind of key you want: [ENTER]
What keysize do you want? [4096]
Key is valid for? [ENTER]
List the long form of the gpg key pair:
gpg --list-secret-keys --keyid-format=long
Add the gpg key pair to your git config:
git config --global user.signingkey GPG-KEY-ID
If you want to automatically sign your commits use:
git config --global commit.gpgSign true
Add this line to your .zshrc
file:
[ -f ~/.zshrc ] && echo 'export GPG_TTY=$(tty)' >> ~/.zshrc
gpg --armor --export GPG-KEY-ID
Now we add the gpg key pair to github in the browser under your settings page.
If you use WSL in combination with VS-Code, you need to setup the GPG pinentry dialog for Windows.
Install the simple installer of the current GnuPG:
GnuPG - Direct Download Link v.2.3.6
Edit the gpg-agent config so it shows the pinentry dialog in Windows:
nano ~/.gnupg/gpg-agent.conf
Paste the following inside:
default-cache-ttl 34560000
max-cache-ttl 34560000
pinentry-program "/mnt/c/Program Files (x86)/gnupg/bin/pinentry-basic.exe"
Restart the gpg agent:
gpgconf --kill gpg-agent
We use the Keychain to save the passphrase to our SSH key, so we don't have to type it with every git command.
Install the keychain tool for Ubuntu:
sudo apt install keychain
Open the zsh shell config and append the following code:
nano ~/.zshrc
# Keychain
/usr/bin/keychain $HOME/.ssh/id_ed25519
source $HOME/.keychain/$HOST-sh