Skip to content

Instantly share code, notes, and snippets.

@nixin72
Last active May 18, 2021 10:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nixin72/20dec757e021bb9e594c6f087acfe609 to your computer and use it in GitHub Desktop.
Save nixin72/20dec757e021bb9e594c6f087acfe609 to your computer and use it in GitHub Desktop.

Installing Windows Subsystem for Linux and integrating it in Visual Studio Code.

Before starting this, the first thing you need to do is make sure your Windows build is up to date enough.

  1. Open "Settings" -> "About"
  2. Scroll to "Windows Specification"
  3. Make sure OS build is 16215 or higher.

Check Windows build number

Enabling Windows Subsystem for Linux

  1. Run PowerShell as an administrator
  2. Run the command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

You may need to restart after this.

Install a Linux distro

  1. Open the Windows store
  2. Search for "Linux", and various distro choices will come up. The options are:
    • Ubuntu
    • OpenSUSE
    • SLES
    • Kali Linux
    • Debian GNU/Linux

If you're not supper familiar with Linux, I recommend Ubuntu. The rest of this will be written assuming you're using Ubuntu, although the rest would be fairly similar. Regardless of what you install, this part can take a while.

Setting Bash to be the default shell in VSCode

  1. Open vscode's settings
  2. Search for terminal.integrated.shell.windows
  3. Change the path to bash or WSL's installed path. This should be C:/Windows/System32/bash.exe.

Now when you open your terminal, you should see this: default bash shell

By this point you should have bash fully working in vscode. The rest of this is to set up the Fish shell to have it look nice and pretty. If you don't want Fish, you're done here.

Setting up Fish to run in vscode

  1. Install fish!
sudo apt-get install fish

If you prefer, you can also install from the git repo: https://github.com/fish-shell/fish-shell#building 2. Install the good stuff:

curl -L https://get.oh-my.fish | curl ; Installs the package manager
omf install agnoster                  ; Installs the agnoster theme - this can be any theme you find here: https://github.com/oh-my-fish/oh-my-fish/blob/master/docs/Themes.md
  1. Open vscode's settings
  2. Search for terminal.integrated.shellArgs.windows
  3. Change the array value to ["-c", "fish"] This will make your startup command when you start the shell bash -c fish

Installing the fonts

  1. Install Powerline fonts on Windows, not bash
git clone https://github.com/powerline/fonts.git --depth=1
./fonts/install.ps1

If you just want a specific font, check out their git repo 2. Open settings in VSCode 3. Go to terminal.integrated.fontFamily 4. Change the value to one of the supported fonts - ex. "Droid Sans Mono Dotted for Powerline"

NOTE:

Make sure your VS Code is up to date. On Insiders < V 1.30 the fonts won't work in the terminal. I don't know what the minimum version is for regular VS Code, but if the fonts don't work, update and you'll be fine.

Now when you open your terminal you should get this: Agnoster theme on VSCode

Important stuff to know

  • Different themes might have different requirements for fonts and such - make sure you're installing them on your Windows local, not through WSL. WSL can't control it's own font because the actual application is run through Windows.
  • You need to be careful about what you're running on WSL because it cannot touch ANY gui applications. All you have access to in it is the linux command line utilities. If you want to edit something for example, it'll need to be through Vim or another editor.
  • The WSL file system is very difficult (if possible at all?) to interact with through Windows. Save your files in Windows and access them through WSL, not vice versa. For example you can't use a WSL path to your Python interpereter for getting Python linting in an IDE - Windows applications can't see into WSL.
@nixin72
Copy link
Author

nixin72 commented Apr 17, 2019

If any of this doesn't work, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment