Kitty Splits With Kakoune

Hello all!

So with Kitty, I have some commands already (that I stole from someone, I can’t remember who lol) for working with Tmux, and I would like to do something similar for Kitty in case I ever use it.

For Tmux I have:

hook global ModuleLoaded tmux %{
    define-command vsplit -docstring "split tmux vertically with `tmux-terminal-horizontal`" \
    -params .. -command-completion %{
        tmux-terminal-horizontal kak -c %val{session} -e "%arg{@}"
    }

    define-command split -docstring "split tmux horizontally with `tmux-terminal-vertical`" \
    -params .. -command-completion %{
        tmux-terminal-vertical kak -c %val{session} -e "%arg{@}"
    }

    define-command tabnew -docstring "create new tmux window with `tmux-terminal-window`" \
    -params .. -command-completion %{
        tmux-terminal-window kak -c %val{session} -e "%arg{@}"
    }
}

And I thought I could do something similar for Kitty:

hook global ModuleLoaded kitty %{
	define-command ktab -docstring "create a new kitty tab with `kitty-terminal-tab`" \
	-params .. -command-completion %{
		kitty-terminal-tab kak -c %val{session} -e "%arg{@}"
	}
	define-command knew -docstring "create a new kitty terminal with `kitty-terminal`" \
	-params .. -command-completion %{
		kitty-terminal kak -c %val{session} -e "%args{@}"
	}
}

However, I would rather make use of a split layout instead of opening a new window or tab. Though I’m not sure if that would be possible.

1 Like

I am not sure if there’s anything implemented to make kitty splits, but you can always consider using a window manager so new kitty windows resize automatically. I am using yabai on macOS and it feels just like working in tmux, if not better.

I’d take a look at the kitty documentation for the remote control protocol. It looks like kitty calls panes windows, so if you pass window type of kitty to the new-window command, it should at least create a split, though I don’t see from a cursory glance how to determine which direction without maybe doing a follow-up command to change the layout of the tab.

1 Like

It’s totally possible, I have a plugin on GitHub that implements a kitty-split function.

Feel free to use it as is or pull whatever you want from it. Good luck!

1 Like