Windows has been notorious for having a poor terminal. Neither the CMD nor PowerShell are very good. In OS, however, you should have a good terminal on your host to enable you to SSH into your VM. Fortunately, Windows now has Windows Subsystem for Linux (WSL) to help with that.
This guide will walk you through how to set up your WSL to give you a better terminal. I will also go through some important changes to give you the best experience.
We first need to enable WSL. To do that, search for Turn Windows features on or
off
This should bring up a dialog box. Scroll to the end and tick the checkbox
for Windows Subsystem for Linux
and restart your computer.
Now that you have enabled WSL, visit the Microsoft Store and search for linux
and download one of the available distros. While you’re at it, I recommend you
download the Windows Terminal (Preview)
(WTP for short) app (you will need to
have Windows 10 version 18362.0 or higher).
To complete the installation of your distro, launch a new instance of it. The first time, it will take a few minutes to complete, and then it will ask to enter a username and password.
At this point, you’ll want to set up your WTP to work for you. Here are some of the important and good settings to change.
To modify the default settings, you will edit profile.json
. To open the file
press Ctrl
+ ,
in WTP. This will launch the default text editor you have set
for JSON files. Here is what yours should look like when you first open
profile.json
.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{abc}",
"profiles":
[
{
// Make changes here to the powershell.exe profile
"guid": "{abc}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile
"guid": "{def}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{ijk}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl"
},
{
"guid": "{xyz}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
}
First, you will want to set the defaultProfile
property to the GUID of the
distro you are running. This will ensure WTP opens with linux.
Next, in the profiles
section you may want to add some custom properties in
your linux distro object. For starters, by default WTP will open in your Windows
User Directory. To force WTP to open in your linux user directory, append the
following line to the JSON object corresponding to your distro.
"startingDirectory": "\\\\wsl$\\\\home\\",
Of course, replace and
with the correct values for your
machine.
You may also want to give your terminal some padding. The code that does that is simply called:
"padding" : "5, 0, 0, 10",
The order the padding will be applied is from left
, top
, right
, bottom
.
In this case, I gave my terminal 5 units padding from the left and 10 from the
bottom.
If you plan to use a custom .bashrc
file that uses the Powerline font, you
should change your default fontFace to one of Powerline Fonts like this.
"fontFace" : "DejaVu Sans Mono for Powerline",
NOTE: make sure you don’t have a comma for the last item in your JSON object.
WTP has the ability to split screen horizontally and/or vertically. To activate
a vertical split use the keyboard shortcut shift
+ alt
+ +
and shift
+
alt
+ -
for a horizontal split.
You can also locate files in your Windows drives with cd /mnt/c/Users/{user}/
for instance, I added
alias win='/mnt/c/Users/Dave/'
alias cwin='cd /mnt/c/Users/Dave/Documents'
to my .bashrc
so that I can copy files and change to work in Windows.