A step-by-step guide to setting up a development environment on Windows Subsystem for Linux (WSL).
This guide walks you through installing and configuring some of the most commonly used tools, helping you get your WSL setup ready for coding quickly and with minimal hassle.
Update the package list and upgrade all installed packages to their latest versions:
sudo apt update
sudo apt upgradeInstall the Git version control system:
sudo apt install gitConfigure your Git identity and default preferences:
git config --global user.name 'McLovin'
git config --global user.email 'McLovin@Superbad.movie'
git config --global init.defaultBranch main
git config --global core.editor 'code --wait'Microsoft recommends installing Git for Windows to share credentials and settings between WSL and Windows. It includes the Git Credential Manager (GCM), which updates with each release.
- Install Git for Windows and select Git Credential Manager (GCM) as the default credential helper.
- Configure WSL Git to use the Windows credential manager:
git config --global credential.helper '/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe'💡 Change the path if Git for Windows is installed in a custom location.
GPG signing allows you to cryptographically sign commits and tags. Choose one of the following approaches based on where you want to manage your GPG keys.
Install GPG4Win on your Windows host. GPG4Win also includes Kleopatra, a certificate manager and GUI for GnuPG. Use it to import an existing key or create a new one, or if you prefer not to use it, you can do the same with the GPG CLI:
Generate a new key:
gpg --full-generate-key🔐 Recommended: Use ECC key (sign and encrypt) with Curve 25519.
Or import an existing key:
gpg --import [SECRET_KEY_FILE_PATH]List your GPG keys to find the key ID:
gpg --list-secret-keys --keyid-format=longThen set the trust level of the imported key:
gpg --edit-key [KEY_ID]In the GPG prompt, set ultimate trust:
gpg> trust
gpg> 5
gpg> y
gpg> quit
Configure Git to use GPG4Win for signing:
git config --global gpg.program '/mnt/c/Program Files (x86)/GnuPG/bin/gpg.exe'
git config --global user.signingkey [KEY_ID]
git config --global commit.gpgsign true
git config --global tag.gpgsign true💡 Change the path if GPG4Win is installed in a custom location.
Verify GUI support is available:
echo $DISPLAYThe expected output is usually :0 or :0.0. If it’s empty, you need to set up WSLg.
Install GPG and the graphical pinentry tool:
sudo apt install gnupg pinentry-gtk2Run the following command to configure the GPG agent to use the graphical pinentry program:
cat << 'EOF' > ~/.gnupg/gpg-agent.conf
pinentry-program /usr/bin/pinentry-gtk-2
default-cache-ttl 28800
max-cache-ttl 86400
EOFRestart the GPG agent to apply the configuration:
gpgconf --kill gpg-agent
gpgconf --launch gpg-agentGenerate a new key:
gpg --full-generate-key🔐 Recommended: Use ECC key (sign and encrypt) with Curve 25519.
Or import an existing key:
gpg --import [SECRET_KEY_FILE_PATH]List your GPG keys to find the key ID:
gpg --list-secret-keys --keyid-format=longThen set the trust level of the imported key:
gpg --edit-key [KEY_ID]In the GPG prompt, set ultimate trust:
gpg> trust
gpg> 5
gpg> y
gpg> quit
Configure Git to use GPG for signing:
git config --global gpg.program gpg
git config --global user.signingkey [KEY_ID]
git config --global commit.gpgsign true
git config --global tag.gpgsign trueInstall the Z shell (Zsh) as an alternative to the default bash shell:
sudo apt install zshInstall the Oh My Zsh framework for managing Zsh configuration:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"Clone and install syntax highlighting plugin:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightingClone and install auto-suggestions plugin:
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsAdd the following plugins to your ~/.zshrc file:
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)🔄 Restart the terminal for changes to take effect.
Install the recommended MesloLGS font family and configure your terminal to use it.
Font Downloads:
- MesloLGS NF Regular | Local Mirror
- MesloLGS NF Bold | Local Mirror
- MesloLGS NF Italic | Local Mirror
- MesloLGS NF Bold Italic | Local Mirror
Clone the PowerLevel10k theme into the Oh My Zsh custom themes directory:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"Update the ZSH_THEME value in your ~/.zshrc file to use the Powerlevel10k theme:
ZSH_THEME="powerlevel10k/powerlevel10k"🔄 Restart the terminal to begin the theme configuration wizard.
Create installation directory and download the installer:
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh🔄 Close and reopen the terminal, or run the following command to activate:
source ~/miniconda3/bin/activateDisable automatic environment activation on terminal startup:
conda config --set auto_activate falseInstall NVM for managing Node.js versions:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash🔄 Close and reopen the terminal, or run the following command to activate:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"Install prerequisites (unzip utility):
sudo apt install unzipDownload and install Deno:
curl -fsSL https://deno.land/install.sh | sh🔄 Restart the terminal for changes to take effect.
Install prerequisites (unzip utility):
sudo apt install unzipDownload and install Bun:
curl -fsSL https://bun.sh/install | bash🔄 Close and reopen the terminal, or run the following command to activate:
exec /usr/bin/zsh