Maxime HEBRARD
Posted on July 26, 2022
At work I often need to use software or CLI only available on Linux, while keeping contact with my co-workers require access to Microsoft Office and other Windows products...
Back in the days, the only solution was to have two machines and transfer data across. Later came the idea of dual boot, installing both OS on one machine. But we needed to reboot the machine everytime we wanted to change OS. Then I came across VirtualBox, a software running on Windows, that allows to install a Linux OS. The limitation was that CPUs, disk space and RAM were divided between the two OS running concurrently, reducing significantly the compute power of the machine.
Today, a new solution exists: Windows Subsystem for Linux (WSL). It allows to install Linux OS, as a software running on Windows. the Linux core has full access to the resources of the machine, and is fully integrated.
WSL Installation
From microsoft.com.
- Prerequisites: Windows 10 Build 19041 and higher.
- Search for
Windows PowerShell
and click on "Run as administrator" - In the terminal, type:
wsl --install
- Reboot the machine
Ubuntu Installation
- Ensure that you are connected to internet.
- Launch the newly installed application "Ubuntu"
- Wait for the installation process
- Enter new UNIX username
- Enter new password
- Retype new password
- Check Linux version
wslfetch
Access files
Note that Windows "do not know about" linux file system, but Linux can access all the files in Windows. By default Windows file system is mounted in Linux at /mnt/c/
. I recommand to create a symlink (shortcut) of Documents
and Downloads
, the most used Windows folders, in Linux home directory. That way, the access to data is simplified.
cd
ln -s /mnt/c/Users/hebrardms/Documents Documents
ln -s /mnt/c/Users/hebrardms/Downloads Downloads
Fonts
We will change the default font of the terminal in preparation for the theme we will install later.
- Open the web browser
- Visit powerlevel10K - Fonts
- Install the recommended fonts (MenloLGS)
- Download the font files from the github links
- Open the .ttf file
- Click on "Install"
- Open Ubuntu
- Right-click on the logo at the top left corner
- Select "Properties"
- Select the font "MesloLGS NF" and size "18"
Color theme
Default terminal colors can be inappropriate. They do not play well with the theme we will install later. To address this issue we will follow tomorrow color theme. Note tomorrow do not provide a theme file dedicated to windows default terminal, but we can define the colors manually.
- Open Ubuntu
- Right-click on the logo at the top left corner
- Select "Properties"
- Select "Colors"
- Update the "Color Values" for each color as per the list below
from base16-tomorrow-night
first column is the original value, third column is the tomorrow theme value
default name tomorrow
38,38,38 - Black - 29,31,33
0,55,218 - Blue - 129,162,190
19,161,14 - Green - 181,189,104
58,150,221 - Cyan - 138,190,183
197,15,31 - Red - 204,102,102
136,23,152 - Purple - 178,148,187
193,156,0 - Yellow - 240,198,116
204,204,204 - White - 197,200,198
118,118,118 - Black - 150,152,150
0,55,218 - Blue - 129,162,190
19,161,14 - Green - 181,189,104
58,150,221 - Cyan - 138,190,183
197,15,31 - Red - 204,102,102
136,23,152 - Purple - 178,148,187
193,156,0 - Yellow - 240,198,116
242,242,242 - White - 255,255,255
- Select the first color
- Click "OK"
Oh My Zsh
WSL come with a minimal terminal. In this section, we will configure the terminal to add some features and style using Oh My ZSH and the theme Powerlevel10k.
- Open "Ubuntu"
# Install Zsh
sudo apt install zsh -y
# Set Zsh as default shell
chsh -s $(which zsh)
# Close Ubuntu
exit
- Open "Ubuntu"
- Setup Zsh, type
0
- Install Oh My Zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
Powerlevel10K
Theme that add useful infomation right in the prompt.
- Open the web browser Visite powerlevel10k
- Follow Powerlevel install instructions...
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
- Install zsh-autosuggestions plugin that provides autocompletion based on our previous commands
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- Install exa a modern replacement for ls.
wget -c http://old-releases.ubuntu.com/ubuntu/pool/universe/r/rust-exa/exa_0.9.0-4_amd64.deb
sudo apt-get install ./exa_0.9.0-4_amd64.deb
- Edit .zshrc to enable powerlevel theme
vim .zshrc
- Press 'insert' to enter insert mode
- Uncomment options and edit file as follow...
# Enable powerlevel10K
# ZSH_THEME="robbyrussell"
ZSH_THEME="powerlevel10k/powerlevel10k"
# Fix pasting URLs and other text messed up.
DISABLE_MAGIC_FUNCTIONS="true"
# Disable colors in ls.
DISABLE_LS_COLORS="true"
# Enable command auto-correction.
ENABLE_CORRECTION="true"
# Display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Disable marking untracked files under VCS as dirty. (much faster)
DISABLE_UNTRACKED_FILES_DIRTY="true"
# Enable plugins
plugins=(git zsh-autosuggestions)
# Alias of ls using exa
if [ -x "$(command -v exa)" ]; then
alias ls="exa --icons"
alias ll="exa --icons --long"
alias la="exa --icons --long --all --group"
alias lt="exa --icons --long --all --group --git --tree"
fi
- Press 'esc' to exit insert mode
- Press ':' and 'x' end 'return' to save and quit the file
- Update Terminal
source .zshrc
- Follow instructions to customise the prompt
Next, I suggest you follow Environment Manager - Conda.
Posted on July 26, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.