[Windows 10] Install, Beautify WSL and My Personal Review
[Preface]
Windows Subsystem for Linux (WSL) is one of the key features developed by
Microsoft recently. Simply put, you can run a Linux environment on Windows,
but unlike using a Virtual Box or VMware, which is a virtual environment.
Basically, you can execute any command, install any package on WSL. It seems
like a little bit superfluous, but we have to admit that sometimes it is
more convenient/efficient to execute some things on Linux. Furthermore, you
can get a gorgeous Terminal, no matter open directly or in VS Code.
However, WSL is not a real Linux after all, and there are bound to be some
disadvantages. In the following, I will provide some pros and cons and some
points of view in my personal use, and instruction on how to install it, use
it, and beautify it.
[Pros & Cons]
- Pros:
- Beautiful Terminal with lots icons, able to use zsh for sure!
- Execute most of the Linux commands, no more suffering from ifconfig and ipconfig [*1]
- Developed by Microsoft. Great compatibility
- Working well with VS Code, also supports Debug mode
- Able to access files from two systems (Windows and WSL)
- Cons:
- Poor performance. Still recommend to run a heavy program on a real OS
- If you're using WSL 2, it will cause some issues of other program, such as Android emulator.
- if you're using Hamachi, it will cause some connection issues on WSL.
To me, these cons are not a real problem. Basically can be fixed or
avoided. However, the two problems with underscore should be more considered. If
you need to use a emulator to run a idle game, play a mobile game on PC,
or need a LAN service to play game with you friends, think more about
it.
[*1]
Starting from Windows10, basically cmd has been replaced by Power Shell.
Some Linux commands can be used in PS, e.g. cd.
[Requirement]
- Latest version of Windows 10, or at least 1903 build.
- Microsoft store
- Knowledge of debugging
Note that WSL is not a basic feature of Windows 10. To install the WSL,
especially WSL 2, you need to turn on some features. And these features are
not turned on by default. It may lead some programs not functional. Be sure
you are able to deal with these problems or recover to the normal
Windows.
[WSL 1? or WSL 2?]
Essentially, I think the fastest way to distinguish which version you
should use is:
Do you need to execute other programs that using virtualization features,
e.g. VMware, Android emulator ?
Microsoft has improved performance on WSL 2, especially file system
(I/O). However, to run WSL 2, you need to turn on Hyper-V. It will make your virtual machine not working.
Personally, I don't feel the performance has a huge improvement on WSL
2. So, I decide to sacrifice performance in exchange for better
compatibility.
You can check the official docs for more information.
[Step by Step]
Here will be divided into several parts, which are WSL 1, WSL 2, and
Beautify. Jump to any section you are interested in by the title. All the commands
are executed under Power Shell. To get more details, click the like
below, which is an official installation guide.
- WSL 1
Enable WSL feature
$ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Open Microsoft Store, choose a Linux version you like
Set up username and password
Done!
- WSL 2
Enable WSL feature
$ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable Virtual Machine Platform feature
$ dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Download Linux kernel update package and install it.
Set default version of WSL
$ wsl --set-default-version 2
Open Microsoft Store, choose a Linux version you like
Set up username and password
(Same as WSL 1)
Done!
- Beautify
After the above steps, you WSL should be execute well. Next, we are going
to install zsh and Powerlevel10K to beautify it. Before starting, I
strongly recommend installing Windows Terminal (yes, it’s called
Terminal..). Easy to use, and work great. You can download it from Microsoft Store. Of course you can use your favorite terminal software.
But I will use Terminal to do the demonstration.
Edit Terminal Setting
Click arrow > Setting
Scroll down a little bit (in the list tag), you can see the
default Terminal type when you open a
new Terminal.
Copy the guid from WSL to defaultProfile, then next time, it will open WSL automatically.
Edit the font
Powerlevel10k recommend using MesloLGS NF.
Edit fontFace to MesloLGS NF
Change themes
Next, let's change a theme, AKA
colorScheme. You can choose any themes from this like:
Or the built-in theme:
If you are using the theme from the first link, you will
get something like this:
{
"name": "OneHalfDark",
"black": "#282c34",
"red": "#e06c75",
"green": "#98c379",
"yellow": "#e5c07b",
"blue": "#61afef",
"purple": "#c678dd",
"cyan": "#56b6c2",
"white": "#dcdfe4",
"brightBlack": "#282c34",
"brightRed": "#e06c75",
"brightGreen": "#98c379",
"brightYellow": "#e5c07b",
"brightBlue": "#61afef",
"brightPurple": "#c678dd",
"brightCyan": "#56b6c2",
"brightWhite": "#dcdfe4",
"background": "#282c34",
"foreground": "#dcdfe4"
}
Copy them into the schemes section.
This is json format, don't forget to check the comma or parentheses!
Terminal settings come to an end!
Install zsh and Powerlevel10k (run in the WSL)
Install zsh
$ sudo apt install zsh
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
After installing done, re-open a Terminal
Install dependency packages
$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
Set up package
open ~/.zshrc , find the following
line and edit it as:
# Use Powerlevel10k theme
ZSH_THEME="powerlevel10k/powerlevel10k"
.
.
.
# Use plugins
plugins=(zsh-autosuggestions zsh-syntax-highlighting)
// you can install any plug-in if needed
If nothing happened, use the following command:
$ p10k configure
Next, answer the question from the configuration wizard and then you will get a wonderful Terminal!
Comments
Post a Comment