Skip to content
Landon edited this page Jan 2, 2022 · 9 revisions

Kakoune seems to compile/work fine with cygwin's g++ or the WSL one. The Windows 10 WSL terminal wasn't able to render kak correctly, but wsltty (https://github.com/mintty/wsltty) works, and the windows 11 WSL terminal works too.

Right-click menu entry

GVim comes with a neat 'Edit with vim' menu entry, the same can be had for kak with a couple registry keys and a shell script. How exactly they work and where they go depends on if you're using cygwin or WSL. I have only tested this on windows 10 and 11, but it should work on older versions as well.

Icon

Windows icons have to be .ico files, which can be made from the .pngs on kakoune.org through various means. I used imagemagick:

wget http://kakoune.org/img/kakoune_logo_32.png
convert kakoune_logo_32.png /kakoune32.ico

Shell script

Cygwin

I have cygwin installed at C:\cygwin64, kakoune installed by a plain make install within that env, and the shell script and icon at C:\cygwin64\kaked.sh and C:\cygwin64\kakoune32.ico. If your installation is different, you'll need to modify paths accordingly.

#!/bin/bash
startkak() {
    echo "Making new session";
    # Remove dead sessions
    kak -clear
    cygstart --hide /usr/local/bin/kak -d -s shell;
    while [ -z $(kak -l|grep shell) ] ; do
        sleep 0.1
    done
    /usr/local/bin/kak -c shell "$@";
}
kak -c shell "$@" || startkak "$@";

WSL

I was unable to compile master kakoune using WSL for windows 10 due to its ancient g++, but it exists in the package repo and could probably be compiled with some determination. Windows 11 has a newer version of g++ and it just works. This can be placed in ~/kaked.sh or something similar

#!/bin/bash
path="$(wslpath $1)"
startkak() {
    echo "Making new session";
    # Remove dead sessions
    kak -clear
    start-stop-daemon --exec /usr/local/bin/kak -b -S -- -d -s shell;
    while [ -z $(kak -l|grep shell) ] ; do
        sleep 0.1
    done
    /usr/local/bin/kak -c shell "$path";
}
kak -c shell "$path" || startkak;

kak.exe (cygwin only)

If kak is installed as /usr/local/bin/kak rather than /usr/local/bin/kak.exe the above won't work (cygstart brings up a "how do you want to open this file" dialog rather than starting kak). I believe if compiled with clang, you'll get the .exe version, if GCC, you'll get the extensionless one, but I haven't had a chance to confirm this. If you have the wrong one, just move it:

mv /usr/local/bin/kak /usr/local/bin/kak.exe

and it'll work correctly. Cygwin seems to have some magic to deal with this, so you won't have to add the '.exe' anywhere else.

Registry Key

Copy the following into a text file ending in '.reg' and right click and "Merge", or add it to the registry manually:

Cygwin

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Kakoune]
@="Open with Kakoune"
"Icon"="\"C:\\cygwin64\\kakoune32.ico\""

[HKEY_CLASSES_ROOT\*\shell\Kakoune\command]
@="C:\\cygwin64\\bin\\mintty.exe -i /kakoune32.ico -o ConfirmExit=no -e /bin/bash -l -e /kaked.sh \"%1\""

WSLtty

WSLtty's installer puts it in %LOCALAPPDATA% but regedit doesn't expand environment variables (it does, but making it do so requires an unreadable hex encoding), so you'll need to insert your own username.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Kakoune]
@="Open with Kakoune"
"Icon"="\"C:\\kakoune32.ico\""

[HKEY_CLASSES_ROOT\*\shell\Kakoune\command]
@="C:\\Users\\<YOURUSERNAME>\\AppData\\Local\\wsltty\\bin\\mintty.exe --WSL= --configdir=\"C:\\Users\\YOURUSERNAME\\AppData\\Roaming\\wsltty\" -~ --exec bash -l ./kaked.sh \"%1\""

Windows Terminal

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Kakoune]
@="Open with Kakoune"
"Icon"="\"C:\\kakoune32.ico\""

[HKEY_CLASSES_ROOT\*\shell\Kakoune\command]
@="wt wsl ~/kaked.sh '%1'"

Better terminal experience

kak runs in MinTTY, the default cygwin terminal emulator, but the default settings lead to limited colors and occasional mojibake.

MinTTY options can be found by right-clicking the titlebar and clicking 'Options.' Make sure that:

  • Under Text, Locale is set
  • Under Text, Character set is UTF-8
  • Under Terminal, Type is xterm-256color
  • Under Terminal, 'Show bold as font' is checked, and 'Show bold as colour' is not.
  • 'Save' to persist changes

Dead daemons

The kak daemon can end up (dead) if it's started in a terminal that gets closed via the windows 'x'. When it does, all the kak windows close abruptly. Also, kak -l takes longer the more dead processes it sees in /tmp, but can't connect to (the files also seem to persist across reboots sometimes), so the script cleans those up. It can be started with cygstart --hide and that seems to get around the issue (but doesn't eliminate the creation of zombie sockets through other means), but that runs in a cmd.exe environment, so it's difficult to wait for the daemon to successfully start before opening a MinTTY connecting to it, so the script spin waits.

Clone this wiki locally