Now I hate Windows less.
Windows subsystem for Linux (WSL) has come out for a while. It started from the insider preview version, migrated to Windows Store, and recently expanded its support to multiple Linux distributions, which caught my eyeball. As a user who ditched Windows for Linux, WSL is intriguing to me and I decided to try it out.
Installation and configuration
I selected the Ubuntu distribution to install. The installation through Windows Store is straightforward. The only thing to note is that, for a first-time installation, the WSL feature has to be enabled through PowerShell
with Administrator privilege,
I had a problem during the installation though, that the process appeared to be frozen. However, when I restarted the computer (hallmark of Windows), it turns out the Ubuntu distribution is already installed in WSL. Due to this detour, I had to set up the user accounts manually in WSL,
Afterwards, one also needs to set the default user for WSL, otherwise the start-up account would still be the root. In PowerShell
do
Finally, upgrade the Ubuntu distribution,
Unlike Windows itself, the WSL does not have a native graphical engine. So interacting with WSL would be like accessing a remote computer. Yet, it is possible to install a third-party X server, e.g. the Xming X server. Make sure Xming is running in Windows, a GUI program in WSL can be invoked as,
Possible application: Editor replacement
In Windows, it is somehow difficult to find a good editor. Maybe that is because Windows has “too” good graphical support than Linux. What I looked for is something like Emacs (or Vim) - lightweight, higly-configurable, highly-extensible, support multiple languages. However, being lightweight appears to be contradict to the rest of the properties. Eventually NotePad++ is down-selected for its lightweightness. Yet, I would not use it to work on large projects. The recent rising star, VS code, is fancy and nice. I like it but it is too heavy for my machine.
I did not try the Emacs for Windows, thought that it is not very meaningful to use Emacs without its ecosystem on Linux. But now, with WSL, why not consider Emacs again?
The installation and the configuration could be done single-handedly in WSL. By configuration I mean copying the files from my config repo. By the way, to download auxiliary files from a code hosting website, the regular wget
might not work, one has to use curl
,
First, the Emacs in terminal mode is tested. Working with terminal mode appears simpler as it does not require Xming
. However, the problem is with the keyboard mapping. I struggled for some time and eventually gave up. The underlying issue is that the terminal interprets whatever the keyboard sends it into a sequence of characters, which are then sent to Emacs. Therefore, Emacs could not get whatever the terminal could not understand. This could result in behaviors like, mapping the arrow keys and Home
/End
keys to the letters ABCDHF. This particular one is easy to fix though, (with ergoemacs mode), by disabling a key binding in the configuration file,
However, there are worse issues. For example, the terminal could not understand the Windows key (i.e. super
key) and differentiate upper and lower cases. There is no way to patch that in Emacs. Working with terminal Emacs is only possible if I gave up half of my customized key-bindings.
Next, I switched to the regular GUI Emacs. The memory usage is around 30 MB (plus 6 MB for Xming), about 2% of what VS code requires. This clears my last concern about the GUI mode - “Emulating” X-server-based GUI does not really take much memory like virtual machine would do. The operation in GUI Emacs is smooth and pretty much the same as that in Linux - except that one need to make sure to have Xming run with the keyhook
option, otherwise the super
could not be picked up. This can be done by modifying the shortcut to the Xming application.
Concerning the comparison between the terminal and GUI modes, there has been quite a few discussions (see references). Looks like people do favor GUI over terminal for Emacs.
For the GUI Emacs, the last issue is to figure out a way to run it easily. It would be tedious to start a bash and type in emacs
before working every time. The solution is surprisingly simple via the short-cut mechanism. Create a shortcut and define the command as
Set the Run
mode to be “Minimized”, so that one do not need to worry about the companying bash window. A logo for the shortcut can be found here.
One final thing to note, the files under Windows can be accessed in WSL by the path \mnt\<disk>\Users\<username>
. To save some effort in typing, one can try the bookmark-set
/bookmark-jump
command in Emacs to record and jump to the location.
References: