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
URLS GROUP 2
URLS GROUP 3
URLS GROUP 4