Skip to content

WSL - Set Up Distro

Set up basics

Update distro

  • update => updates the database of packages (list of versions etc)
  • upgrade => actually updates the packages
  • Hence first run update to get a fresh list and then run upgrade to update the packages
  • Note : You can use apt install -y PACKAGE_NAME to assume a "yes" answer to any prompts
sudo apt update && sudo apt upgrade

Tools

  • Zsh
    sudo apt install zsh
  • Set up Zsh and set it as the default shell
    Run zsh and follow instructions
    To get back to this menu:
    autoload -Uz zsh-newuser-install
    zsh-newuser-install -f
  • Oh-my-zsh
    • download it via curl as per instructions on project page
      sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    • follow instructions
  • Install powerline fonts if needed for Oh My Zsh themes, etc sudo apt install powerline fonts-powerline
  • Midnight Commander
    sudo apt install mc
  • Git : update git to latest version
    • First add Git maintainers' PPA:
      sudo add-apt-repository ppa:git-core/ppa
    • Then update repository directory:
      sudo apt update
    • Finally, 'install' git to get the updated version (even if it was already installed)
      sudo apt install git
  • Tree
    sudo apt install tree

  • Fix the directory background on the ls command.
    Add the following to .bashrc or .zshrc

# FROM : https://github.com/lloydstubber/my-wsl-setup#fix-the-ls-and-cd-colours
#Change ls colours
LS_COLORS="ow=01;36;40" && export LS_COLORS

Git

  • Use Ubuntu/WSL Git for cloning repos (e.g. some cli apps are installable via Git)

  • Use the Git from Windows to manage my own repos

  • Install Git for Windows.org
  • Install Git Credential Manager
  • When working with GitHub repos, the Git Credential Manager will *magically* kick in and manage the credentials.

Other Stuff

  • Set a symlink/mount point to a working directory in windows
    sh # move to home directory cd # set symlink to working folder ln -s /mnt/c/bin
  • Set a setup file to save all installed items & to easily set up a new distro
# set up wsl setup file  
touch wsl_setup.sh

# give it execute permission
chmod 755 /mnt/c/wsl_setup.sh

# to edit it with VS Code
code wsl_setup.sh 

# to send commands to the wsl_setup.sh file, example:
echo "sudo apt install mc #install midnight commander" >> wsl_setup.sh

Set up for Python

Pyenv

  • Dependencies for pyenv
    • Supposedly this is only required if installing from source (downloading Git repo & building)
    • However on my Ubuntu 18.04 (LTS) in WSL the Python build failed, so I installed the dependencies as described here :
      sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
  • Use the installer script from the installer project Pyenv Installer curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
    or
    curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | zsh
  • Add pyenv to the load path (add the following lines to .zhrc or .bashrc)
export PATH="/home/ska2/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
  • Restart the shell
    exec "$SHELL"

Python Interpreter

  • To check available Python interpreters for installation, run :
    pyenv install --list
  • Install the interpreter required, e.g. for 3.8.2 run :
    pyenv install 3.8.2
  • Set the global Python interpreter if required :
    pyenv global 3.8.2

Python Project Environment

This is standard Pyenv stuff:

  • Create a virtualenv : pyenv virtualenv 3.7.7 MYENVNAME
  • Then activate it pyenv activate MYENVNAME
  • Or : Go to directory and do pyenv local 3.7.7 and create a virtualenv there

REF

Links I found useful about WSL, Git and WSL, etc here.

First, shout out to Scott Hanselman from whose blog I learnt A LOT. Many thanks your way Scott :)

URLS GROUP 1

https://medium.com/@johnbwoodruff/epic-dev-environment-with-wsl-dc81e234ae61 | Epic Development Environment using Windows Subsystem for Linux https://github.com/sirredbeard/Awesome-WSL | GitHub - sirredbeard/Awesome-WSL: Awesome list dedicated to Windows Subsystem for Linux https://github.com/rodtreweek/Castle-Winbuntu#install-pyenv | GitHub - rodtreweek/Castle-Winbuntu: Homesick Castle for use on WSL. https://keestalkstech.com/2019/12/visual-studio-code-docker-python-using-wsl-in-windows-on-boot-camp/ | Visual Studio Code + Docker + Python using WSL in Windows on Boot Camp https://github.com/jlevy/the-art-of-command-line | GitHub - jlevy/the-art-of-command-line: Master the command line, in one page https://stackoverflow.com/questions/44441830/vscode-use-wsl-git-instead-of-git-for-windows | visual studio code - VSCode: use WSL Git instead of Git for Windows - Stack Overflow https://github.com/lloydstubber/my-wsl-setup#fix-the-ls-and-cd-colours | GitHub - lloydstubber/my-wsl-setup: Quick rundown on my current setup on the Windows Subsystem for Linux. https://towardsdatascience.com/jupyter-lab-evolution-of-the-jupyter-notebook-5297cacde6b?source=---------8------------------ | Jupyter Lab: Evolution of the Jupyter Notebook - Towards Data Science https://github.com/junegunn/fzf | GitHub - junegunn/fzf: A command-line fuzzy finder https://code.visualstudio.com/docs/remote/troubleshooting#_sharing-git-credentials-between-windows-and-wsl | Visual Studio Code Remote Development Troubleshooting Tips and Tricks https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly | Setting Up Docker for Windows and WSL to Work Flawlessly — Nick Janetakis https://nickjanetakis.com/blog/configuring-wsltty-which-is-my-favorite-windows-wsl-terminal | Configuring wsltty Which Is My Favorite Windows WSL Terminal — Nick Janetakis https://medium.com/@janelgbrandon/a-guide-for-using-wsl-for-development-d135670313a6 | A guide for using WSL for development - Janel Brandon - Medium https://www.hanselman.com/blog/SettingUpAShinyDevelopmentEnvironmentWithinLinuxOnWindows10.aspx | Setting up a Shiny Development Environment within Linux on Windows 10 - Scott Hanselman https://nickjanetakis.com/blog/conemu-vs-hyper-vs-terminus-vs-mobaxterm-terminator-vs-ubuntu-wsl | ConEmu vs Hyper vs Terminus vs MobaXTerm Terminator vs Ubuntu WSL — Nick Janetakis https://code.visualstudio.com/docs/remote/wsl | Developing in the Windows Subsystem for Linux with Visual Studio Code https://code.visualstudio.com/docs/remote/linux | Linux Prerequisites for Visual Studio Code Remote Development https://gitforwindows.org/ | Git for Windows https://github.com/andy-5/wslgit | GitHub - andy-5/wslgit: Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode) https://docs.microsoft.com/en-us/windows/wsl/install-win10 | Install Windows Subsystem for Linux (WSL) on Windows 10 | Microsoft Docs https://medium.com/faun/how-to-use-git-and-other-linux-tools-in-wsl-on-windows-4c0bffb68b35 | How to use GIT and other Linux tools in WSL on Windows https://peteoshea.co.uk/setup-git-in-wsl/ | Setup Git in WSL - Pete O'Shea

URLS GROUP 2

https://docs.microsoft.com/en-us/windows/python/web-frameworks | Web development with Python on Windows | Microsoft Docs https://help.github.com/en/github/using-git/which-remote-url-should-i-use | Which remote URL should I use? - GitHub Help https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line | Creating a personal access token for the command line - GitHub Help https://blog.mikepearce.net/2010/05/18/the-difference-between-git-pull-git-fetch-and-git-clone-and-git-rebase/ | The difference between git pull, git fetch and git clone (and git rebase) – Mike Pearce https://stackoverflow.com/questions/26460415/gerrit-git-pull-vs-checkout-vs-cherrypick-which-is-for-what | gerrit - git (pull vs checkout vs cherrypick) which is for what? - Stack Overflow

URLS GROUP 3

https://dev.to/davidshare/setting-up-a-python-development-environment-with-pipenv-3lfj | Setting up a Python development environment with pipenv - DEV Community 👩‍💻👨‍💻 https://medium.com/telnyx-engineering/rip-pipenv-tried-too-hard-do-what-you-need-with-pip-tools-d500edc161d4 | RIP Pipenv: Tried Too Hard. Do what you need with pip-tools. https://github.com/pyenv/pyenv-installer | GitHub - pyenv/pyenv-installer: This tool is used to install pyenv and friends. https://itsfoss.com/install-git-ubuntu/ | How to Install the Latest Git Version on Ubuntu https://xunnanxu.github.io/2018/05/13/Building-Linux-Workspace-on-Windows-10-via-WSL/ | Building Linux Workspace on Windows 10 via WSL - Shawn's Pitstop https://hihigash.com/how-install-pyenv-to-ubuntu-on-windows-adf48cc0577f?gi=ee7763bb8c33 | How install “pyenv” to Ubuntu on windows 10? - hihigash's weblog https://keestalkstech.com/2019/12/visual-studio-code-docker-python-using-wsl-in-windows-on-boot-camp/ | Visual Studio Code + Docker + Python using WSL in Windows on Boot Camp https://medium.com/@realck/setting-up-django-in-wsl-with-vscode-remote-development-e043d8f8d1d8 | Setting up Django in WSL with VSCode Remote Development https://github.com/pyenv/pyenv | GitHub - pyenv/pyenv: Simple Python version management

URLS GROUP 4

https://gioele.io/pyenv-pipenv | Installing Python packages in 2019: pyenv and pipenv https://medium.com/powershell-explained/text-editor-inside-powershell-22d2f5e748b8 | Text Editor inside PowerShell - PowerShell Explained - Medium https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/ | The Beginner’s Guide to Nano, the Linux Command-Line Text Editor https://www.hanselman.com/blog/HowToMakeAPrettyPromptInWindowsTerminalWithPowerlineNerdFontsCascadiaCodeWSLAndOhmyposh.aspx | How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh - Scott Hanselman https://github.com/lloydstubber/my-wsl-setup#fix-the-ls-and-cd-colours | GitHub - lloydstubber/my-wsl-setup: Quick rundown on my current setup on the Windows Subsystem for Linux. https://github.com/microsoft/PowerToys | GitHub - microsoft/PowerToys: Windows system utilities to maximize productivity https://stackoverflow.com/questions/51584765/how-do-you-install-multiple-separate-instances-of-ubuntu-in-wsl | windows subsystem for linux - How do you install multiple, separate instances of Ubuntu in WSL? - Stack Overflow https://www.webdevdrops.com/en/git-on-windows-github-install-configure/ | Git on Windows and GitHub: How to Install and Configure | Web Dev Drops https://www.computerhope.com/issues/ch001927.htm | How to install and use Git on Windows https://github.com/desktop/desktop/issues/3708 | Add option during install to add git to path in Windows · Issue #3708 · desktop/desktop · GitHub https://gitforwindows.org/ | Git for Windows https://github.com/desktop/desktop/issues/340 | What are we gonna do about Git Shell on Windows · Issue #340 · desktop/desktop · GitHub https://blog.anaisbetts.org/using-github-credentials-in-wsl2/ | Using GitHub HTTPS Credentials in WSL 2 | Thursday Night https://www.hanselman.com/blog/CoolWSLWindowsSubsystemForLinuxTipsAndTricksYouOrIDidntKnowWerePossible.aspx | Cool WSL (Windows Subsystem for Linux) tips and tricks you (or I) didn't know were possible - Scott Hanselman