7c54de2334
When launch matches using `id` kitty tries to match against tab id before matching windows. When there are multiple tabs it's likely to match a tab before matching a window. Use `window_id` directly to avoid any possiblity of matching tabs. This is only needed for `kitty @ launch` for other commands there is no specific `window_id` field.
57 lines
1.4 KiB
Plaintext
57 lines
1.4 KiB
Plaintext
hook global ModuleLoaded kitty %{
|
|
require-module kitty-repl
|
|
}
|
|
|
|
provide-module kitty-repl %{
|
|
|
|
define-command -params .. \
|
|
-docstring %{
|
|
kitty-repl [<arguments>]: Create a new window for repl interaction.
|
|
|
|
All optional parameters are forwarded to the new window.
|
|
} \
|
|
kitty-repl %{
|
|
nop %sh{
|
|
if [ $# -eq 0 ]; then
|
|
cmd="${SHELL:-/bin/sh}"
|
|
else
|
|
cmd="$*"
|
|
fi
|
|
|
|
match=""
|
|
if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then
|
|
match="--match=window_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 launch --no-response --keep-focus --type="$kak_opt_kitty_window_type" --title=kak_repl_window --cwd="$PWD" $match $cmd
|
|
}
|
|
}
|
|
complete-command kitty-repl shell
|
|
|
|
define-command -hidden -params 0..1 \
|
|
-docstring %{
|
|
kitty-send-text [text]: Send text to the REPL window.
|
|
|
|
If no text is passed, the selection is used.
|
|
} \
|
|
kitty-send-text %{
|
|
nop %sh{
|
|
if [ $# -eq 0 ]; then
|
|
text="$kak_selection"
|
|
else
|
|
text="$1"
|
|
fi
|
|
kitty @ send-text --match=title:kak_repl_window "$text"
|
|
}
|
|
}
|
|
|
|
alias global repl-new kitty-repl
|
|
alias global repl-send-text kitty-send-text
|
|
|
|
}
|