Setting Up Development In Wsl
August 09, 2020By the end of this guide, you’ll have the following installed:
WSL
This guide will use “Ubuntu”. So your mileage may vary.
Enable the feature
You will be prompted to restart your machine after enabling.
Search for “Turn Windows features on or off”.
And check the option that says “Windows Subsystem for Linux”.
Download Ubuntu from the store
As of this writing, the “Ubuntu” with no version number is 20.04
.
Converting to WSL 2
Open powershell and wsl --set-version <name> 2
on the distro you want to upgrade.
To move your projects to the WSL network, just do explorer.exe .
on the directory like ~/projects
to open it in the File Explorer and copy your files.
To open your projects in VSCode, navigate to the directory and do code .
.
Copy and Pasting
Right click on the title bar of the Ubuntu terminal and click on Properties. In the Options tab, check “Use Ctrl+Shift+C/V as Copy/Paste”
Fonts
Some characters will not work out of the box. I’m currently using “DejaVu Sans Mono for Powerline”.
Download is available here ↗️
Git
Install Git
Set your identity
A better git log
Use it by running git lg
Colors available are: normal
, black
, red
, green
, yellow
, blue
, magenta
, cyan
, white
Attributes available: bold
, dim
, ul
, blink
, reverse
Configure Git to push on current branch
To avoid pushing to the wrong branch, especially master.
When doing a push
, no need to specify to which branch. Just run git push origin
and it will push to whatever branch you’re currently on.
Hub
This is optional.
Hub
is a superset ofgit
like howTypeScript
is a superset ofJavaScript
.
With hub
you can do a pull request to github by running hub pull-request -b <branch> -m <pr_message>
.
Generate SSH key
ZSH Shell
I prefer zsh but you can replace it with others like fish or just the default bash shell.
Install ZSH
You’ll be greeted with this screen, select the (q)
option.
Installing Oh my ZSH
Auto suggest
Using plugins in ZSH
Edit your ~/.zshrc
file and find the plugins section
Refresh zsh to apply the changes
Node
This will install Node using nvm to avoid using sudo
Install by nvm (Recommended)
The normal way which will require sudo
Reinstalling node
tmux
Install tmux
Configuring tmux
Create a tmux configuration file
Add the 1st part on the config for now
Installing plugins
This will install the following plugins:
- tpm
- tmux-sensible
- tmux-resurrect
- tmux-prefix-highlight
Add the rest of the config
There’s no progress indicator but once complete this screen will show
tmux key combinations
prefix
means crtl+a or whichever prefix you have set.prefix
% - split horizontallyprefix "
- split verticallyprefix ctrl+s
- save layout for tmux-resurrectprefix ctrl+r
- reload layoutprefix c
- create a windowprefix w <window_number>
- switch to a windowprefix x
- close a paneprefix
z - make pane fullscreen
prefix z
is important because you aren’t able to highlight multiple lines in a vertical pane because the other panes will be highlighted too.
other key combinations
To highlight texts inside WSL while using tmux you’ll have to hold down shift
and highlight.
- ctrl+shift+c - copy highlighted text
- ctrl+shift+v - paste to terminal while using tmux
Refer to #copy-and-pasting for the combinations above
If you’re using Windows Terminal ↗️, you still need to hold shift when highlighting but you can use the normal ctrl+c
and ctrl+v
.
Update history:
- Jan 20, 2021 - updated nvm section, add
source ~/.nvm/nvm.sh
- Jan 20, 2021 - updated tmux section, add
tmux
command to go to tmux - Feb 09, 2021 - add
setopt HIST_IGNORE_SPACE
- Aug 09, 2022 - remove
setopt HIST_IGNORE_SPACE
, update stuff