Install a Less Sad Terminal in Windows Subsystem for Linux

I thought what I'd do was, I'd pretend I was one of those X Window Systems...

Featured image

By the end of this walkthrough post you should be the proud owner of a shiny new XTerm instance running on top of an VcXsrv, an X Window Server package, on your Windows machine. This is a massive step up from the less than stellar terminal that comes with Windows Subsystem for Linux installs which appears to be built on most of the guts of either the Powershell or legacy Command Prompt terminals.

The default WSL terminal includes sadness like only being able to paste by right clicking the title bar and clicking Edit > Paste and playing the bell sound every time it can’t match what you’re trying to tab or type. Using XTerm will resolve these issues and enable a bunch of useful features such as:

Installing the X Window Server

Download VcXsrv from SourceForge: https://sourceforge.net/projects/vcxsrv/

Run the installer and follow the bouncing ball.

image image image

Run Xlaunch under Start > VcXsrv and follow the bouncing ball to configure the X Window Server.

image image image

As part of the last step for the configurator, save your configuration if you don’t want to click thorugh the configurator every time you launch VcXsrv. It will output a .config file associated with VcXsrv which you can double click to launch the application without reconfiguring it.

image

You want to make sure that you’re not punching a hole through Windows firewall. The X Window server is designed to allow remote connections on a shared system, much in the same vein as remote desktop provides gui sessions for Windows machines. We don’t need this functionality if we’re only planning to bind to the X Window server locally.

image

Configuring WSL for the X Window Server and XTerm

Define the environment variable DISPLAY="localhost:0.0" in .bashrc

kitsutron@lappentoppen:~$ echo 'DISPLAY="localhost:0.0"' >> ~/.bashrc

Install XTerm.

sudo apt update && sudo apt install xterm -y

Create a reasonable colour profile for xterm in your home directory inside WSL.

kitsutron@lappentoppen:~$ cat <<'_EOF_' >>~/.XTerm
XTerm*background:  #000000
XTerm*foreground:  #9f9f9f
XTerm*color0:      #000000
XTerm*color1:      #9e1828
XTerm*color2:      #aece92
XTerm*color3:      #968a38
XTerm*color4:      #414171
XTerm*color5:      #963c59
XTerm*color6:      #418179
XTerm*color7:      #bebebe
XTerm*color8:      #666666
XTerm*color9:      #cf6171
XTerm*color10:     #c5f779
XTerm*color11:     #fff796
XTerm*color12:     #4186be
XTerm*color13:     #cf9ebe
XTerm*color14:     #71bebe
XTerm*color15:     #ffffff
_EOF_

Launch xterm from WSL.

kitsutron@lappentoppen:~$ xterm

Extra Goodness

For extra points, create a desktop shortcut to launch XTerm and your favorite terminal multiplexer. If you’re not a tmux user, just drop tmux off the end of the shortcut path.

C:\Users\kitsutron\AppData\Local\Microsoft\WindowsApps\kali.exe run export DISPLAY='localhost:0.0'; xterm tmux

You can also set up VcXsrv to launch every time Windows starts by adding it to your startup programs if you prefer not to run it manually.