I recently retired my 7-year-old laptop in favor of a (refurbished) beast of a Dell laptop that I got for software development and media creation. Here, I summarize setting up:

  1. Git
  2. Powershell and Windows Terminal
  3. Windows Subsystem for Linux (WSL)
  4. VS Code.

Git

Setting up Git for Windows is simple: just run the installer. Note:

  • To test your installation, run git --version
  • Git for Windows provides Git at the command line from within Windows itself, from a Windows, Powershell, or Git Bash prompt (Git Bash comes with Git for Windows).
  • Once you install WSL, though (see below), you’ll have access to a Linux version Git from inside WSL. That makes two different versions of Git.
  • Related, but not essential, programs:

Powershell and Windows Terminal

Powershell (not “Windows Powershell”)

For mysterious reasons, Windows ships only with Windows Powershell, which is not the Powershell you want. You want just plain Powershell. Install it.

Windows Terminal

Grab the Windows Terminal (Preview) from the Microsoft app store (or the non-preview edition if you’re cautious).

Next, set up fancy prompts on Windows (prompts for WSL are a slightly different issue; see next section):

  • There are basically three steps: (1) install programs for customizing prompts, (2) install fonts, and (3) configure various terminals.
  • Programs to install:
    • posh-git
      • To enable it in Powershell1 inside Windows Terminal, I edited $profile.CurrentUserAllHosts to add the line Import-Module posh-git
    • oh-my-posh
      • The installation instructions and the oh-my-posh Powershell FAQ will get you started.
        • Note: This is no longer installed as a Powershell module; many online instructions are outdated.
      • Pick a theme - I like montys
      • Edit a PowerShell profile of your choice to add a line like this (replace the theme name):
        oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\montys.omp.json" | Invoke-Expression
        
  • Fonts: download and install a nerd font you like. Note:
    • VS Code’s integrated terminal only likes monospace fonts.
    • Not everyone likes ligatures (I don’t).
    • Not every font has every icon your oh-my-posh theme might call for. If you see squares instead of icons in your prompt, try a different font.
    • You may want to install the font for all users to avoid potential problems. (I’m not sure this is needed; it’s a guess based on posts I’ve seen.)
      • If you have a choice between TTF and OTF fonts, pick OTF. The easiest way to install fonts is from a font file’s right-click menu.
    • I went with DejaVuSansMono Nerd Font, which seems to have lots of icons.
  • Terminal and program configuration:
    • Edit the Windows Terminal settings.json file to specify the fontFace.2 To set the font for all terminals, add it to the defaults section (you could also add a font for a specific terminal in the list section):
            "defaults": 
          {
              "fontFace":  "DejaVuSansMono Nerd Font"
          },
      
    • Note: you must use the font name as shown in the Windows Fonts interface (Control Panel → All Control Panel Items → Fonts). The font’s filename won’t do it.

To modify the list of prompts shown in Windows Terminal to add an admin prompt:

  • Edit the Terminal’s settings.json file so that the terminal of your choice has "elevate": true. You can infer the rest of the format from existing entries.

Windows Subsystem for Linux (WSL)3

Since my laptop is brand new (to me), I expected WSL to be installed, or at least to be easy to install. It was neither. This post on cloudbytes.dev by Rehan Haider has simple instructions on setting up WSL and would have saved me some time.

Installation

  • On most new Windows systems, wsl --install should do the job.
  • On my system, I had to:
    • Enable WSL and Virtual Machine Platform.
      • With GUI: Control panel → Programs → Turn Windows features on and off → (1) check Windows Subsystem for Linux, (2) check Virtual Machine Platform
      • Or at command line (elevated prompt):
        dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
        dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
        
  • Install WSL
    • I think I was able to run wsl --install after enabling it, but I’m not sure.
    • Microsoft’s instructions tell you to download an installer for WSL. I’m sure that works too.
  • Update WSL.
    • Even though the installation seemed fine, Docker complained, and I had to update WSL immediately after installation. Not sure if I used the command line or an installer.
  • Install a Linux distro (Ubuntu 20.04) in WSL. I did not use the Microsoft store; I did it from the command line.
  • For all of this, wsl --help is your friend.

Prettifying WSL Prompts

There are probably three ways to do this: (1) using Powerline-go within WSL, (2) using regular Powerline within WSL (tutorial), or (3) using oh-my-posh, which has a Linux version, within WSL.

  • I say “probably” because I chose option (1), based on Scott Hanselman’s outdated blog post, without really thinking it through. If I do this again, I’ll try option (3).
  • Using Powerline-go:
    • First, install Go. I did not use apt, because the available Go version is outdated.
    • Next, install Powerline-go:
      go install github.com/justjanne/powerline-go@latest
      
    • Then edit your .bashrc file per the installation instructions.
      • If you use VS Code, you can open .bashrc from the WSL prompt this way:4
        cd ~
        code ./.bashrc
        
      • There area lot of command-line options you can set to customize the prompt. I went with:
        function _update_ps1() {
          PS1="$($GOPATH/bin/powerline-go -error $? \
              -jobs $(jobs -p | wc -l) \
              -condensed \
              -newline \
              -truncate-segment-width 10 \
              -cwd-max-depth 4)"
        }
        

VS Code

The terminal in VS Code uses its own fonts, so to get the same pretty prompts inside VS Code that you are getting elsewhere, you need to modify VS Code’s settings.json:

  • In the command palette (Ctrl-Shift-P), enter JSON and select Preferences: Open Settings (JSON)
  • In settings.json, add an entry for your nerd font:
      "terminal.integrated.fontFamily": "DejaVuSansMono Nerd Font"
    
  • If you don’t like ligatures, also add this entry:
      "editor.fontLigatures": false
    

1There are four different PowerShell profiles, from the possible combinations of these two-element pairs: (AllUsers, CurrentUsers) and (AllHosts, CurrentHost).

  • The AllUsers profiles are stored in the system Powershell directory; the CurrentUsers profiles are stored in the user’s PowerShell directory.
  • The AllHosts files are called profile.ps1. The CurrentHost files are called Microsoft.PowerShell_profile.ps1
  • If you use the $profile variable to refer to them, you don’t really need to know (but can find out) where they are.

2VS Code gives you this warning about fontFace in settings.json: [deprecated] Define ‘face’ within the ‘font’ object instead. I am not sure what, if anything, to do about this.

3Theoretically, there are two WSLs, WSL1 and WSL2. But as of this writing, WSL2 is the only one that matters.

4I think that code ~/.bashrc should also work from anywhere, but I found it unreliable (sometimes it would open my Windows home directory, not my WSL home directory). Explicitly changing to home (~) in WSL first was reliable.