diff --git a/rc/windowing/kitty.kak b/rc/windowing/kitty.kak index a6ff4180..5790a7c4 100644 --- a/rc/windowing/kitty.kak +++ b/rc/windowing/kitty.kak @@ -8,23 +8,24 @@ evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ "$TERM" = "xterm-kitty" ] || echo 'fail Kitty not detected' } -declare-option -docstring %{window type that kitty creates on new and repl calls (kitty|os)} str kitty_window_type kitty +declare-option -docstring %{window type that kitty creates on new and repl calls (window|os-window)} str kitty_window_type window define-command kitty-terminal -params 1.. -shell-completion -docstring ' 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="" + 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" $match "$@" - else - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --window-type "$kak_opt_kitty_window_type" --cwd "$PWD" $match "$@" + listen="" + if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then + listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi + + kitty @ $listen launch --no-response --type="$kak_opt_kitty_window_type" --cwd="$PWD" $match "$@" } } @@ -33,16 +34,17 @@ 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="" + 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" $match "$@" - else - kitty @ --to "$kak_client_env_KITTY_LISTEN_ON" new-window --no-response --new-tab --cwd "$PWD" $match "$@" + listen="" + if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then + listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi + + kitty @ $listen launch --no-response --type=tab --cwd="$PWD" $match "$@" } } @@ -54,13 +56,17 @@ If no client is passed then the current one is used' \ if [ $# -eq 1 ]; then printf "evaluate-commands -client '%s' focus" "$1" else - if [ -z "$kak_client_env_KITTY_LISTEN_ON" ]; then - 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 --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 + match="" + if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then + match="--match=id:$kak_client_env_KITTY_WINDOW_ID" fi + + listen="" + if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then + listen="--to=$kak_client_env_KITTY_LISTEN_ON" + fi + + kitty @ $listen focus-window --no-response $match fi } }