WSL2 + Windows Terminal setup

WSL (Windows Subsystem for Linux) is quite awesome, as it allows you to run your code as you would natively on Linux. This can run on both Windows Home and Pro (it used to be exclusive to Pro). As the install might change in the future, I'd best link to an official Microsoft tutorial. Before you click on that, I'd recommend setting the WSL to version 2 BEFORE installing your distribution of preference + use the manual install as you probably don't have the insiders preview: https://docs.microsoft.com/en-us/windows/wsl/install-win10.

As the tutorial by microsoft mentions Windows Terminal is very nice, just like the Linux distribution you install this via the Microsoft store. In addition to simply installing the application I would recommend to set some basic settings (adjust these according to need of course):

startingDirectory: \wsl$\Ubuntu-20.04\home\{username}

Default terminal (pick your distro or whatever you prefer)

Icon per terminal-type

Hotkeys at least look at the list because it is useful

Additional terminals:

It is quite easy to have additional terminals that for example automatically connect to a server or use the windows program GitBash for example. The only thing you need to do is configure the commandline of said terminals. (id_rsa if configured on said server can do the authentication for you)

Whatcommandline
GitBash\"%PROGRAMFILES%\git\bin\bash.exe\" --login -i -l
Serverssh {user}@{ip} -p 22 -i ~/.ssh/id_rsa
use Windows GitBash or connect straight to a server

If you will have many different profiles, it might be a good idea to add different background images to those terminals as well.

Extra tips:

  • To quickly access your current directory in file explorer, use "explorer.exe ." this works in all terminals (on the local machine)
  • WSL(2) works great with docker, currently i only use linux based-terminals on windows.
  • If you are going to make auto-connects to many servers, it is a good idea to set a background-image to those such that you quickly know what kind of server you are on.
  • Custom fonts and looks: Install zsh and oh-my-zsh: https://github.com/ohmyzsh/ohmyzsh some notable themes that i liked: josh, pmcgee and risto.
  • In a future update Linux GUI programs are supported and would run like any native Windows program.
  • for changing cursor in vim, edit ~/.vimrc (1 block, 3 underscore, 5 bar +1 not blinking):

if &term =~ '^xterm'    let &t_EI .= "\[1 q"    let &t_EI .= "\[6 q"endi