Upgrade to Pro — share decks privately, control downloads, hide ads and more …

macOS-like Developer Experience with WSL2, Wind...

Kohei Ota
September 10, 2020

macOS-like Developer Experience with WSL2, Windows Terminal, VSCode and Docker Desktop

Talked at microWSLConf 2020

Kohei Ota

September 10, 2020
Tweet

More Decks by Kohei Ota

Other Decks in Technology

Transcript

  1. macOS-like Developer Experience with WSL2, Windows Terminal, VSCode and Docker

    Desktop microWSLConf 2020 Kohei Ota, Hewlett Packard Enterprise / CNCF Ambassador GitHub: @inductor, Twitter: @_inductor_
  2. Agenda • What’s macOS like DX? • Tools and where

    they cover • Real world issues and workarounds • Customizing and sharing
  3. This talk does not cover • What are WSL and

    WSL2 ◦ WSL2 architecture and such • How to use macOS • How to use Docker
  4. What’s macOS-like DX? • Runs shell natively • IDE and

    filer integration • Easy tab management just like browsers • Better copy-and-paste experience than classic cmd.exe ◦ Just use Ctrl+C and Ctrl-V • Package management • Runs code quickly and easily! (w/ the power of Docker)
  5. What’s macOS-like DX? • Runs shell natively • IDE and

    filer integration • Easy tab management just like browsers • Better copy-and-paste experience than classic cmd.exe ◦ Just use Ctrl+C and Ctrl-V • Package management • Runs code quickly and easily! (w/ the power of Docker) WSL2 Windows Terminal Homebrew Docker Desktop VSCode
  6. Windows vs macOS features comparison macOS Windows Shell environment Native

    WSL2 IDE and filer integration Native VSCode + Bash script Easy tab management Terminal.app / iTerm2 Windows Terminal + Config Copy and Paste (C+C/C+V) Terminal.app / iTerm2 Windows Terminal + Config Package management Homebrew + dotfiles Homebrew + dotfiles Run code quickly and easily Docker Desktop for Mac Docker Desktop for Windows
  7. VSCode Remote + WSL2 • VSCode has supported WSL2 remote

    since the end of 2019 ◦ https://code.visualstudio.com/blogs/2019/09/03/wsl2 • Type ‘code’ in your WSL bash and it will launch VSCode! ◦ https://code.visualstudio.com/docs/remote/wsl-tutorial#_run-in-wsl
  8. Reproduce ‘open’ command in WSL2 • macOS shells support ‘open’

    command to open directories in their filer ◦ e.g. “open .” and it will open the current directory on Finder • In WSL, you just need this one line in your .bashrc :) ◦ alias open="powershell.exe /c start"
  9. Introduce Windows Terminal • Windows Terminal is a new Terminal

    officially developed by Microsoft ◦ Supports powershell, cmd and WSL background • Fully open source on GitHub ◦ https://github.com/microsoft/terminal • Available on Microsoft Store
  10. Customize Windows Terminal • All settings are configurable with JSON

    format "profiles": { "list": [ { "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", "hidden": false, "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu/home/kela", "fontFace": "Roboto Mono for Powerline" } ] } Set your $HOME for new tabs!
  11. Customize Windows Terminal • All settings are configurable with JSON

    format Copy and Paste Tab management Key bindings "keybindings": [ { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }, { "command": "paste", "keys": "ctrl+v" }, { "command": "closeTab", "keys": "ctrl+w" }, { "command": "newTab", "keys": "ctrl+t" }, { "command": "find", "keys": "ctrl+shift+f" }, ]
  12. Homebrew supports Linux • https://docs.brew.sh/Homebrew-on-Linux ◦ WSL support included! •

    Homebrew installer now runs pure bash and brew contains portable ruby ◦ Better portability and less external dependency
  13. Make your dotfiles • Manage your brew install and bashrc

    changes on GitHub ◦ https://github.com/inductor/dotfiles • When you get a new computer, just run dotfiles installer then you’re all set!
  14. Docker Desktop for Windows • Now it supports WSL2 on

    Windows 10 Home 1903/1909 • I’d personally recommend Edge channel ◦ New features & performance fixes come more frequently • Developing inside a Container ◦ https://code.visualstudio.com/docs/remote/containers
  15. • Set .wslconfig in %UserProfile%\.wslconfig • Here’s my personal setting

    • Available options are on https://docs.microsoft.com/en-us/windows/wsl/wsl-config Memory usage explosion in WSL2 [wsl2] memory=6GB swap=0 processors=4
  16. • The best workaround right now is not to use

    Windows filesystem • VSCode Remote and Docker and IDE integration with WSL2 make it possible • I strongly recommend the ‘open’ command support if you want to use explorer.exe with working directories! Memory usage explosion in WSL2
  17. Key takeaways Windows has become very developer friendly It’s nice

    to have a workstation that both my favourite software work: Age of Empires 2 and Docker! WSL2 still has problems, but it is already enough for most users who use macOS for Web development Windows Terminal keybindings are powerful WSL2 networking and filesystem shareing is convenient