Skip to content

Instantly share code, notes, and snippets.

@jdalley
Last active January 9, 2023 14:01
Show Gist options
  • Save jdalley/0daa2885a4ef78c5bf937b99d32c8b78 to your computer and use it in GitHub Desktop.
Save jdalley/0daa2885a4ef78c5bf937b99d32c8b78 to your computer and use it in GitHub Desktop.
Windows Subsystem for Linux (WSL) - Ubuntu Setup

Steps for setting up a decent looking WSL Ubuntu terminal

Install and configure the WSL/Ubuntu console:

  • Enable WSL on Windows 10 through 'Programs and Features'.
  • Install WSL Ubuntu from the Windows Store.
  • Launch ubuntu.exe and do initial 'Properties/Defaults' config:
    • Right click on the title bar, select Defaults:
      • Under the Options tab, select Use Ctrl+Shift+C/V as Copy/Paste
      • You might want to increase Buffer Size for Command History under the Options tab, and Height under Layout > Screen Buffer Size: 9001 seems like enough 😄

We're in, and it looks... dark and contrasty! now what?

  • Install zsh:
    • sudo apt-get install zsh
    • After it installs, type zsh and choose a configuration (I chose 2)
  • Install oh-my-zsh:
    • Using curl:
      sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    • This will clone the repo and replace the existing ~/.zshrc with a template from oh-my-zsh.
  • Configuring zsh/oh-my-zsh:
    • The install might have made zsh your Login Shell, you can check with: chsh, it will print something like:
      Changing the login shell for <name>
      Enter the new value, or press ENTER for the default
                Login Shell [/usr/bin/zsh]:
      
    • If it already says, as above, /usr/bin/zsh, then you're good to go, if not:
      • Make zsh the default for Bash: chsh -s $(which zsh)
        • Since the Windows 10 Spring 2018 Creator's Update, you can use cshs like you would in mainline Linux systems.
  • Changing directory colors:
    • The default colors used in ls at this point have some bad background highlighting issues, let's fix that.
    • Create a .dircolors file as follows: dircolors -p > ~/.dircolors
      • You now have a .dircolors file containing the color configuration for ls, which is stored in the env variable LS_COLORS. What we need to do next is make a change to the colors, and save it back to LS_COLORS.
    • Edit ~/.dircolors, we're removing the background from OTHER_WRITABLE, and fixing the font color for the rest:
      • Change SETUID to: SETUID 00;30;41
      • Change SETGID to: SETUID 00;30;43
      • Change CAPABILITY to: CAPABILITY 00;30;41
      • Change STICKY_OTHER_WRITABLE to: STICKY_OTHER_WRITABLE 00;30;42
      • Change OTHER_WRITABLE to: OTHER_WRITABLE 01;32
      • Change STICKY to: STICKY 00;30;44
      • Save
    • Edit ~/.zshrc and add the following:
      • eval `dircolors ~/.dircolors`
      • Save and restart ubuntu.exe
  • Change the overall terminal Color theme:
  • Change themes and colors of oh-my-zsh:
    # Find and change this:
    ZSH_THEME="robbyrussell"
    
    # To this:
    ZSH_THEME="agnoster"
    
  • Fix missing font symbols:
    • You'll notice some symbols are missing, this is because you need a Powerline font that will work for Windows + Windows Consoles.
    • Download/clone the following repo: https://github.com/powerline/fonts
    • Open the DejaVuSansMono folder, and install DejaVu Sans Mono for Powerline.ttf
      • This is the only font I found that actually works with all the symbols used in oh-my-zsh agnoster.
    • Right-click on the title-bar of your Ubuntu terminal, select Defaults:
      • In the Font tab, select DejaVu Sans Mono for Powerline
      • In the Colors tab, set Opacity to 90%, you're a real hipster now.
      • Hit OK, then restart ubuntu.exe

Vim Setup

  • Vim comes with some default color schemes that you can change, which are found here: /usr/share/vim/vim80/colors
    • You can try a scheme out in vim with: :colorscheme <theme>
    • To have it launch with a given theme, add it to ~/.vimrc: colorscheme elflord
    • You can also grab any number of other vim themes and put them in ~/.vim/colors, where colorscheme will find them by name.
  • Gruvbox theme: https://github.com/morhetz/gruvbox

Links used for Theme and Color:

Additional links:

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