Coder's Cat

Random WSL Tips & Tricks

2021-06-02

Quick launch of Linux terminal

img:wsl-luach

Quick access to the home directory of Linux

Paste this file address to explorer. Here the ubuntu is your Linux distribution’s Name:

\\wsl$\ubuntu

Quick access current directory with explore.exe:

explorer.exe .

Copy the content of a file in WSL to Windows System

cat report.txt | clip.exe

Open VSCode

Launch VSCode and open current directory as a open project.

code .

Launch VSCode and open file with name of demo.js.

code demo.js 

Shutdown or restart a distribution

Sometimes, Linux will hang on for some weird reasons. We can try to shutdown it to make it normal.

wslconfig /L        # to list all distributions 
wslconfig /t Ubuntu # shutdown your wsl distribution

Restart the whole WSL Service

Open powershell with Admin privileges and type the below command to restart the lxxsManger:

Get-Service LxssManager | Restart-Service

Set the Teminal starting directory

We need to do some modifications for settings.json for WSL. Ctrl-, to open setting panel , choose the terminal profile and then select the starting directory.

starting directory

Use the awesome programmer friendly font

Firecode

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')

# or shorter
iwr -useb get.scoop.sh | iex

scoop bucket add nerd-fonts
scoop install firacode

Join my Email List for more insights, It's Free!😋