From bdee3abd88ebc88ef39d47c6c8c63694d90bd3f2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 1 Mar 2021 08:47:09 +1100 Subject: [PATCH] Match on kitty window id when available This ensures new window are created in the same os window as the current client instead of the default one. Closes #4009 --- rc/windowing/kitty.kak | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/rc/windowing/kitty.kak b/rc/windowing/kitty.kak index 2cbbd74a..a6ff4180 100644 --- a/rc/windowing/kitty.kak +++ b/rc/windowing/kitty.kak @@ -15,10 +15,15 @@ kitty-terminal []: create a new terminal as a kitty window The program passed as argument will be executed in the new terminal' \ %{ nop %sh{ + local match="" + if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then + match="--match=id:$kak_client_env_KITTY_WINDOW_ID" + fi + if [ -z "$kak_client_env_KITTY_LISTEN_ON" ]; then - kitty @ new-window --no-response --window-type "$kak_opt_kitty_window_type" --cwd "$PWD" "$@" + kitty @ new-window --no-response --window-type "$kak_opt_kitty_window_type" --cwd "$PWD" $match "$@" else - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --window-type "$kak_opt_kitty_window_type" --cwd "$PWD" "$@" + kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --window-type "$kak_opt_kitty_window_type" --cwd "$PWD" $match "$@" fi } } @@ -28,10 +33,15 @@ kitty-terminal-tab []: create a new terminal as kitty tab The program passed as argument will be executed in the new terminal' \ %{ nop %sh{ + local match="" + if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then + match="--match=id:$kak_client_env_KITTY_WINDOW_ID" + fi + if [ -z "$kak_client_env_KITTY_LISTEN_ON" ]; then - kitty @ new-window --no-response --new-tab --cwd "$PWD" "$@" + kitty @ new-window --no-response --new-tab --cwd "$PWD" $match "$@" else - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --new-tab --cwd "$PWD" "$@" + kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --new-tab --cwd "$PWD" $match "$@" fi } } @@ -45,11 +55,11 @@ If no client is passed then the current one is used' \ printf "evaluate-commands -client '%s' focus" "$1" else if [ -z "$kak_client_env_KITTY_LISTEN_ON" ]; then - kitty @ focus-tab --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID - kitty @ focus-window --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID + kitty @ focus-tab --no-response --match=id:$kak_client_env_KITTY_WINDOW_ID + kitty @ focus-window --no-response --match=id:$kak_client_env_KITTY_WINDOW_ID else - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" focus-tab --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" focus-window --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID + kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" focus-tab --no-response --match=id:$kak_client_env_KITTY_WINDOW_ID + kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" focus-window --no-response --match=id:$kak_client_env_KITTY_WINDOW_ID fi fi }