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 runupgrade
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
Runzsh
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
- download it via curl as per instructions on project page
- 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
- First add Git maintainers' PPA:
-
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
- Epic Development Environment using Windows Subsystem for Linux
- GitHub - sirredbeard/Awesome-WSL: Awesome list dedicated to Windows Subsystem for Linux
- GitHub - rodtreweek/Castle-Winbuntu: Homesick Castle for use on WSL.
- Visual Studio Code + Docker + Python using WSL in Windows on Boot Camp
- GitHub - jlevy/the-art-of-command-line: Master the command line, in one page
- visual studio code - VSCode: use WSL Git instead of Git for Windows - Stack Overflow
- GitHub - lloydstubber/my-wsl-setup: Quick rundown on my current setup on the Windows Subsystem for Linux.
- Jupyter Lab: Evolution of the Jupyter Notebook - Towards Data Science
- GitHub - junegunn/fzf: A command-line fuzzy finder
- Visual Studio Code Remote Development Troubleshooting Tips and Tricks
- Setting Up Docker for Windows and WSL to Work Flawlessly — Nick Janetakis
- Configuring wsltty Which Is My Favorite Windows WSL Terminal — Nick Janetakis
- A guide for using WSL for development - Janel Brandon - Medium
- Setting up a Shiny Development Environment within Linux on Windows 10 - Scott Hanselman
- ConEmu vs Hyper vs Terminus vs MobaXTerm Terminator vs Ubuntu WSL — Nick Janetakis
- Developing in the Windows Subsystem for Linux with Visual Studio Code
- Linux Prerequisites for Visual Studio Code Remote Development
- Git for Windows
- GitHub - andy-5/wslgit: Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)
- Install Windows Subsystem for Linux (WSL) on Windows 10 | Microsoft Docs
- How to use GIT and other Linux tools in WSL on Windows
- Setup Git in WSL - Pete O'Shea
URLS GROUP 2
- Web development with Python on Windows | Microsoft Docs
- Which remote URL should I use? - GitHub Help
- Creating a personal access token for the command line - GitHub Help
- The difference between git pull, git fetch and git clone (and git rebase) – Mike Pearce
- gerrit - git (pull vs checkout vs cherrypick) which is for what? - Stack Overflow
URLS GROUP 3
- Setting up a Python development environment with pipenv - DEV Community 👩💻👨💻
- RIP Pipenv: Tried Too Hard. Do what you need with pip-tools.
- GitHub - pyenv/pyenv-installer: This tool is used to install
pyenv
and friends. - How to Install the Latest Git Version on Ubuntu
- Building Linux Workspace on Windows 10 via WSL - Shawn's Pitstop
- How install “pyenv” to Ubuntu on windows 10? - hihigash's weblog
- Visual Studio Code + Docker + Python using WSL in Windows on Boot Camp
- Setting up Django in WSL with VSCode Remote Development
- GitHub - pyenv/pyenv: Simple Python version management
URLS GROUP 4
- Installing Python packages in 2019: pyenv and pipenv
- Text Editor inside PowerShell - PowerShell Explained - Medium
- The Beginner’s Guide to Nano, the Linux Command-Line Text Editor
- How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh - Scott Hanselman
- GitHub - lloydstubber/my-wsl-setup: Quick rundown on my current setup on the Windows Subsystem for Linux.
- GitHub - microsoft/PowerToys: Windows system utilities to maximize productivity
- windows subsystem for linux - How do you install multiple, separate instances of Ubuntu in WSL? - Stack Overflow
- Git on Windows and GitHub: How to Install and Configure | Web Dev Drops
- How to install and use Git on Windows
- Add option during install to add git to path in Windows · Issue #3708 · desktop/desktop · GitHub
- Git for Windows
- What are we gonna do about Git Shell on Windows · Issue #340 · desktop/desktop · GitHub
- Using GitHub HTTPS Credentials in WSL 2 | Thursday Night
- Cool WSL (Windows Subsystem for Linux) tips and tricks you (or I) didn't know were possible - Scott Hanselman