Skip to content
Bruno Heridet edited this page Jul 20, 2017 · 9 revisions

Kakoune seems to compile/work fine with cygwin's g++

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. I have only tested this on Windows 10, but it should work on older versions as well. 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.

Icon

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

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

Shell script

#!/bin/bash
startkak() {
    echo "Making new session";
    # Remove dead sessions
    for SESSION in $(kak -l |grep dead| cut -d' ' -f 1) 
    do
        echo "Deleting dead session $SESSION"
        rm /tmp/kakoune/$USER/$SESSION
    done
    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 "$@";

Registry Key

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

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\""

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