Skip to content

Windows tips

Magus Zeal edited this page Dec 20, 2017 · 4 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
    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 "$@";

kak.exe

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:

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.

You can’t perform that action at this time.