From 66ac92718c80dfce62bac23e93e5576711bd8318 Mon Sep 17 00:00:00 2001 From: Jake Koroman Date: Mon, 8 Jun 2026 20:16:31 -0400 Subject: kakoune hacking. --- kak/kakrc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/kak/kakrc b/kak/kakrc index 8ed04a7..ea20142 100644 --- a/kak/kakrc +++ b/kak/kakrc @@ -29,32 +29,37 @@ hook global ModuleLoaded wayland %{ hook global ModuleLoaded tmux %{ set global windowing_placement 'horizontal' + evaluate-commands %sh{ + copy_cmd="wl-copy" + paste_cmd="wl-paste" + if [ -z "$WAYLAND_DISPLAY" ]; then + copy_cmd="xclip -selection clipboard" + paste_cmd="xclip -selection clipboard -o" + fi + printf "map -docstring 'yank to system clipboard' global user y '%s'\n" "$copy_cmd" + printf "map -docstring 'paste from system clipboard' global user p '%s'\n" "$paste_cmd" + } } hook global BufWritePre .* %{ jrk-trim-trailing-whitespace } -define-command testcmd %{ - prompt -file-completion 'What is your name? ' %{ - evaluate-commands %sh{ - echo "Hello, $kak_text!" > /tmp/vars - env >> /tmp/vars - title=$(dmenu -p 'say something: ') - printf "info '%s' -title '%s'" "wrote to file /tmp/vars" "$title" - } - } -} - define-command jrk-set-makecmd-and-make %{ - prompt 'makecmd: ' %{ + prompt -file-completion 'makecmd: ' %{ evaluate-commands %{ set-option global makecmd %val{text} - make + jrk-save-and-make } } } +define-command jrk-save-and-make %{ + evaluate-commands %sh{ + [ "$kak_bufname" != "*make*" ] && printf "evaluate-commands %%{ write\nmake }\n" + } +} + define-command jrk-trim-trailing-whitespace %{ try %{ execute-keys -draft "%%s\h+$d" } } @@ -62,7 +67,7 @@ define-command jrk-trim-trailing-whitespace %{ map -docstring 'goto next make error' global user [ '<:>make-next-error' map -docstring 'goto previous make error' global user ] '<:>make-previous-error' -map -docstring 'save file and run make' global user q '<:>w<:>make' +map -docstring 'save file and run make' global user q '<:>jrk-save-and-make' map -docstring 'set makecmd and make' global user Q '<:>jrk-set-makecmd-and-make' map -docstring 'edit file' global user . '<:>edit ' -- cgit v1.2.3