2020-04-15 21:49:01 +02:00
|
|
|
hook global ModuleLoaded kitty %{
|
|
|
|
require-module kitty-repl
|
|
|
|
}
|
|
|
|
|
|
|
|
provide-module kitty-repl %{
|
|
|
|
|
2022-02-22 10:14:47 +01:00
|
|
|
define-command -params .. \
|
2020-04-15 21:49:01 +02:00
|
|
|
-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
|
2021-03-04 20:43:13 +01:00
|
|
|
|
|
|
|
match=""
|
|
|
|
if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then
|
2023-05-07 12:04:55 +02:00
|
|
|
match="--match=window_id:$kak_client_env_KITTY_WINDOW_ID"
|
2021-03-04 20:43:13 +01:00
|
|
|
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
|
2020-04-15 21:49:01 +02:00
|
|
|
}
|
|
|
|
}
|
2022-02-22 10:14:47 +01:00
|
|
|
complete-command kitty-repl shell
|
2020-04-15 21:49:01 +02:00
|
|
|
|
|
|
|
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
|
2021-03-04 20:43:13 +01:00
|
|
|
kitty @ send-text --match=title:kak_repl_window "$text"
|
2020-04-15 21:49:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 12:30:34 +02:00
|
|
|
alias global repl-new kitty-repl
|
|
|
|
alias global repl-send-text kitty-send-text
|
2020-04-15 21:49:01 +02:00
|
|
|
|
|
|
|
}
|