All notes tagged with wsl.

Switching between devices with Syncthing

I have a desktop machine running Linux and a Macbook running MacOS, and I often switch between devices while working on a project.

Now, I can sync states using Git, but I often find that doing so makes me create pointless commits just to sync states.

That’s where I started using Syncthing on all my devices. I’ll leave installing Syncthing for you, the reader, but there is one handy trick I think you need to know.

If you create a .stignore file in your project root, and you add:

#include .gitignore

It will take your .gitnore and exclude the items in it from being synced. This is helpful for reducing the size of the sync but also means that you won’t sync build artifacts, which may not be compatible across devices.

Try it out!

August 23, 2023

vim wsl

Copy/Paste for Neovim in WSL

If you want a seamless copy/paste experience on Neovim in WSL there is a newly recommended method for doing so, without having to install extra software.

Paste the following Lua snippet in your configuration and "+y to yank the selected text into your global register. Similarly, use "+p to paste.

if vim.fn.has "wsl" == 1 then
  vim.g.clipboard = {
    name = "WslClipboard",
    copy = {
      ["+"] = "clip.exe",
      ["*"] = "clip.exe",
    paste = {
      ["+"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
      ["*"] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    cache_enabled = 0,

August 22, 2023

windows wsl

Faster key repeat on Windows

With WSL, Windows can be a great developer experience. The one thing which I did find lacking, especially when moving around in Vim, is that the maxixmum key repeat rate in the configuration panel is too slow.

I was able to fix that with the following settings in Regedit:

[HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response]

You have to login and out again for it to take effect.

October 12, 2022

emacs wsl

Emacs on Windows WSL2

So, it turns out that WSL2 is actually kind of neat, where it runs a Linux image at almost native speed, and also supports Wayland.

So, what’s the first thing you do in WSL2? Install Emacs of course!

Below is the script I use to install Emacs on an Ubuntu image.

To know what the latest stable version on master is, I look at this Github issue from Jim Myhrberg, who keeps track of those.

# Checkout Emacs
$ git clone git://

# Checkout latest stable version, see note above.
$ git checkout 8febda4

# Vanilla Emacs requirements
$ sudo apt install build-essential autoconf libgtk-3-dev libgnutls28-dev libtiff5-dev libgif-dev libjpeg-dev libpng-dev librsvg2-dev libxpm-dev libncurses-dev texinfo adwaita-icon-theme-full

# Native compilation requirements
$ sudo apt install libgccjit-11-dev

# Required for Native JSON
$ sudo apt install libjansson4 libjansson-dev

# Required for tree-sitter support
$ sudo apt install libtree-sitter-dev

$ cd emacs
$ export CC=/usr/bin/gcc-11 CXX=/usr/bin/gcc-11
$ ./
$ ./configure --with-pgtk --with-native-compilation --with-tree-sitter --with-json --without-pop
$ make -j$(nproc)
$ sudo make install

And, sometimes when you update the repository, it refuses to build. I usually fix that with running make bootstrap er make distclean.

September 7, 2022


Syncthing on WSL2

I like to use Syncthing to sync files between accounts and machines, and now even between my Windows subsystem and Windows itself.

To run Syncthing on WSL I use this script:

#!/usr/bin/env bash

if ! pgrep -x "$SERVICE" >/dev/null
        daemonize /usr/bin/syncthing serve "$OPTS"

Make sure to change your username and to make the port unique, if you run multiple Syncthings on your machine.