Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iex "& {$(irm get.scoop.sh)} -ScoopDir ${Env:USERPROFILE}\Scoop"
scoop install git; scoop bucket add extras; scoop bucket add nerd-fonts
scoop install --global JetBrains-Mono Maple-Mono Maple-Mono-NF Meslo-NF-Mono Monaspace
#
winget install Docker.DockerDesktop
winget install JanDeDobbeleer.OhMyPosh
winget install Microsoft.PowerShell
winget install Microsoft.VisualStudioCode
#
wsl --install --distribution Ubuntu-22.04
Restart-Computer
#
code --install-extension ms-vscode-remote.remote-wsl
wsl --install --distribution Ubuntu-22.04
wsl --update
#
wsl --user root -- sh -c 'apt update --yes && apt upgrade --yes && apt autoremove --yes'
# Prompt should be 'normal' or 'never'
wsl --user root -- sh -c "sed -i 's/Prompt=lts/Prompt=normal/g' /etc/update-manager/release-upgrades"
wsl --user root -- sh -c "sed -i 's/Prompt=lts/Prompt=never/g' /etc/update-manager/release-upgrades"
wsl --user root -- sh -c 'do-release-upgrade'
wsl --user root -- sh -c 'apt update --yes && apt upgrade --yes && apt autoremove --yes'
#
wsl --shutdown
mkdir E:\WSL
wsl --export Ubuntu-22.04 "E:\WSL\Ubuntu-23.10.tar"
wsl --unregister Ubuntu-22.04
wsl --import Ubuntu-23.10 "E:\WSL\Ubuntu-23.10" "E:\WSL\Ubuntu-23.10.tar"
wsl --set-default Ubuntu-23.10
# if you didn't install Docker Desktop or you need Docker in WSL
sudo apt update --yes && sudo apt upgrade --yes
mkdir -p ~/Downloads
curl -fsSL https://get.docker.com -o ~/Downloads/get-docker.sh
sudo sh ~/Downloads/get-docker.sh
sudo usermod -aG docker $USER
sudo apt autoremove --yes
rm ~/Downloads/get-docker.sh
#
sudo apt install --yes exiftool
base_url=https://github.com/dandavison/delta/releases/download
delta_version=0.17.0
filename="git-delta_${delta_version}_amd64.deb"
curl -fsSL "${base_url}/${delta_version}/${filename}" -o ~/Downloads/$filename
sudo dpkg --install git-delta_${delta_version}_amd64.deb
rm ~/Downloads/$filename
#
sudo apt install --yes zsh
gist_base=https://raw.githubusercontent.com
sh -c "$(curl -fsSL ${gist_base}/ohmyzsh/ohmyzsh/master/tools/install.sh)"
plugins_path="${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins"
git config --global url."https://github.com/".insteadOf gh:
git clone gh:z-shell/F-Sy-H "${plugins_path}/F-Sy-H"
git clone gh:zsh-users/zsh-autosuggestions "${plugins_path}/zsh-autosuggestions"
sed -ie "s/plugins=.*/plugins=(git F-Sy-H zsh-autosuggestions)/g" ~/.zshrc
source ~/.zshrc
# bash -c "$(curl -sSL ${gist_base}/nandordudas/a80971a3cf4a4563a26bc9aa3cfc8c00/raw/git_config)"
file_hash=94b3917fd77133fc310aeb62fad8a7c1d8ff3d1261324fb5fedfe1fb57b33c21
gist_base=https://gist.githubusercontent.com
curl -fsSL ${gist_base}/nandordudas/a80971a3cf4a4563a26bc9aa3cfc8c00/raw/git_config -o ~/Downloads/git_config
diff <(sha256sum ~/Downloads/git_config | awk '{print $1}') <(echo ${file_hash})
bash ~/Downloads/git_config
rm ~/Downloads/git_config
Install Scoop a command-line installer for Windows
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
iex "& {$(irm get.scoop.sh)} -ScoopDir ${Env:USERPROFILE}\Scoop"
scoop install git
scoop bucket add extras
scoop install delta exiftool
Windows Package Manager and PowerShell
winget upgrade --all --silent --include-unknown
winget install Microsoft.PowerShell
winget install Microsoft.PowerToys
Font settings
Monaspace, Maple mono, Nerd fonts
scoop bucket add nerd-fonts
scoop install --global Monaspace JetBrains-Mono Maple-Mono Maple-Mono-NF Meslo-NF-Mono
Customize Powershell
Install-Module Terminal-Icons
winget install JanDeDobbeleer.OhMyPosh
Update Powershell profile setup.
winget install Microsoft.VisualStudioCode
code $PROFILE
Add Microsoft.PowerShell_profile.ps1 content and save the file.
Update Windows Terminal settings and set it as the default profile. Disable the logo on your PowerShell profile by adding -NoLogo
after the command and save the changes, like \pwsh.exe -NoLogo
- go to Settings/Defaults/Font face
and set Maple Mono NF
.
Install Visual Studio Code and Docker Desktop
winget install Docker.DockerDesktop
winget install Microsoft.VisualStudioCode
Note
If using Docker Desktop is not feasible or undesirable.
# WSL already installed
sudo apt update --yes && sudo apt upgrade --yes
mkdir -p ~/Downloads
curl -fsSL https://get.docker.com -o ~/Downloads/get-docker.sh
sudo sh ~/Downloads/get-docker.sh
sudo usermod -aG docker $USER
sudo apt autoremove --yes
rm ~/Downloads/get-docker.sh
# If you encounter issues with Docker setup, consider deleting the ~/.docker folder both on the host and within WSL
Open Windows Terminal with Administrator permissions
Setup the new user. These commands are running in Powershell, not in WSL.
# Set up Ubuntu within WSL or choose a particular release, such as Ubuntu-22.04
wsl --install --distribution Ubuntu
Restart-Computer
# To rerun the previous command, use the up arrow key in the terminal, and WSL will update the kernel
wsl --install --distribution Ubuntu
wsl --update
wsl --user root apt update --yes
wsl --user root apt upgrade --yes
# Check system info
wsl lsb_release --all
# Set default distribution
wsl --list
wsl --set-default Ubuntu
# Prepare WSL image upgrade - cat /etc/os-release
sudo apt install update-manager-core
# Upgrade WSL image - use the "-d" flag if you want use development versions
sudo do-release-upgrade
sudo apt update --yes && sudo apt upgrade --yes
sudo apt install --yes zsh
sudo apt autoremove --yes
It's recommended to export your WSL image to an external disk for space-saving and backup purposes.
wsl --shutdown
mkdir E:\WSL
wsl --export Ubuntu-22.04 "E:\WSL\Ubuntu-23.10.tar"
wsl --unregister Ubuntu-22.04
wsl --import Ubuntu-23.10 "E:\WSL\Ubuntu-23.10" "E:\WSL\Ubuntu-23.10.tar"
wsl --set-default Ubuntu-23.10
Tip
Add WSL config on the host
Check wslconfig. Restart WSL and Docker.
wsl --shutdown
code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-vscode-remote.remote-wsl
Note
You don't need to setup Git on host but recommended to set email and name globally.
Use Windows Terminal or VS Code, or use WSL Bash.
# On WSL Ubuntu
base_url=https://github.com/dandavison/delta/releases/download
delta_version=0.17.0
filename="git-delta_${delta_version}_amd64.deb"
curl -fsSL "${base_url}/${delta_version}/${filename}" -o ~/Downloads/$filename
sudo dpkg --install git-delta_${delta_version}_amd64.deb
sudo apt install --yes exiftool
rm ~/Downloads/$filename
# Arch
# sudo pacman -S git-delta perl-image-exiftool
Setup zsh
Oh-My-Zsh, Powerlevel 10k, Fast syntax highlight and Zsh completions
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
plugins_path="${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins"
git config --global url."https://github.com/".insteadOf gh:
git clone gh:z-shell/F-Sy-H "${plugins_path}/F-Sy-H"
git clone gh:zsh-users/zsh-autosuggestions "${plugins_path}/zsh-autosuggestions"
sed -ie "s/plugins=.*/plugins=(git F-Sy-H zsh-autosuggestions)/g" ~/.zshrc
source ~/.zshrc
Git setup
Please check git_config file below before run following script!
bash -c "$(curl -sSL https://gist.githubusercontent.com/nandordudas/a80971a3cf4a4563a26bc9aa3cfc8c00/raw/git_config)"
Folder specific Git configuration
git config --global --edit
[includeIf "gitdir:~/Code/Github/"]
path = ~/Code/Github/.gitconfig
Use local repositories like that:
- ~/Code/GitHub/johndoe
- /repository_one
- /repository_two
- ~/Code/GitHub/janedoe
- /repository_one
- /repository_two
- ~/Code/GitLab/janedoe
- /repository_one
Add refspec
The +refs/merge-requests/*:refs/remotes/origin/merge-requests/*
refspec tells
Git to fetch all merge requests from the remote repository. The *
wildcard
matches all merge requests, and the :refs/remotes/origin/merge-requests/*
part tells Git to store the fetched merge requests in the
refs/remotes/origin/merge-requests/*
namespace.
git config --add remote.origin.fetch "+refs/merge-requests/*:refs/remotes/origin/merge-requests/*"
The +refs/pull/*/head:refs/remotes/pull_requests/*
refspec tells Git to fetch
the heads of all pull requests from the remote repository. The
refs/pull/*/head
part matches the heads of all pull requests,
and the :refs/remotes/pull_requests/*
part tells Git to store the fetched
heads in the refs/remotes/pull_requests/*
namespace.
git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/pull_requests/*"
The +refs/pull-requests/*/from:refs/remotes/origin/pr/*
refspec tells Git to
fetch the from branches of all pull requests from the remote repository.
The refs/pull-requests/*/from part matches
the from branches of all pull
requests, and the :refs/remotes/origin/pr/*
part tells Git to store the
fetched branches in the refs/remotes/origin/pr/*
namespace.
git config --add remote.origin.fetch "+refs/pull-requests/*/from:refs/remotes/origin/pr/*"
Note
I you have issues with signing commits with GPG key.
GPG for Win, sharing GPG keys and about commit signature verification
Please check what sudo does before installing it, or simply use the terminal as an administrator and execute the command without it.
scoop install sudo
sudo scoop install gpg4win
# Restarting the computer is recommended, but even signing off is sufficient
Logoff
Log back into WSL. Enjoy.