summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-09-27 19:08:47 +1000
committerMaxime Coste <mawww@kakoune.org>2018-09-27 19:08:47 +1000
commit004ed72f441e35f01ad99d2c20c83c8a84c63099 (patch)
tree14920e0a5022a49529e3ec8e3d6767ebafae7bb1
parent6a82398d0fff0118dfadbd48902bf88b1bc81d26 (diff)
parentd06e8d662d55294fb9d6c3d850bbc01daf3aa215 (diff)
Merge remote-tracking branch 'laelath/kitty-qol-commands'
-rw-r--r--rc/extra/kitty.kak34
1 files changed, 32 insertions, 2 deletions
diff --git a/rc/extra/kitty.kak b/rc/extra/kitty.kak
index 73c0b9e2..3365afe2 100644
--- a/rc/extra/kitty.kak
+++ b/rc/extra/kitty.kak
@@ -1,8 +1,13 @@
-hook global KakBegin .* %sh{
+declare-option -docstring %{window type that kitty creates on new and repl calls (kitty|os)} str kitty_window_type kitty
+
+hook -group kitty-hooks global KakBegin .* %sh{
if [ "$TERM" = "xterm-kitty" ] && [ -z "$TMUX" ]; then
echo "
alias global new kitty-new
+ alias global new-tab kitty-new-tab
alias global focus kitty-focus
+ alias global repl kitty-repl
+ alias global send-text kitty-send-text
"
fi
}
@@ -12,7 +17,15 @@ Optional arguments are passed as arguments to the new client} \
-params .. \
-command-completion \
kitty-new %{ nop %sh{
- kitty @ new-window --no-response "$(command -v kak 2>/dev/null)" -c "${kak_session}" -e "$*"
+ kitty @ new-window --no-response --window-type $kak_opt_kitty_window_type "$(command -v kak 2>/dev/null)" -c "${kak_session}" -e "$*"
+}}
+
+define-command -docstring %{kitty-new-tab [<arguments>]: create a new tab
+All optional arguments are forwarded to the new kak client} \
+ -params .. \
+ -command-completion \
+ kitty-new-tab %{ nop %sh{
+ kitty @ new-window --no-response --new-tab "$(command -v kak 2>/dev/null)" -c "${kak_session}" -e "$*"
}}
define-command -params ..1 -client-completion \
@@ -22,7 +35,24 @@ If no client is passed then the current one is used} \
if [ $# -eq 1 ]; then
printf %s\\n "evaluate-commands -client '$1' focus"
else
+ 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
fi
+}}
+
+define-command -docstring %{kitty-repl [<arguments>]: create a new window for repl interaction
+All optional parameters are forwarded to the new window} \
+ -params .. \
+ -shell-candidates %{
+ find $(echo $PATH | tr ':' ' ') -mindepth 1 -maxdepth 1 -executable -printf "%f\n"
+ } \
+ kitty-repl %{ evaluate-commands %sh{
+ if [ $# -eq 0 ]; then cmd="${SHELL:-/bin/sh}"; else cmd="$*"; fi
+ kitty @ new-window --no-response --window-type $kak_opt_kitty_window_type --title kak_repl_window $cmd < /dev/null > /dev/null 2>&1 &
+}}
+
+define-command kitty-send-text -docstring "send the selected text to the repl window" %{
+ nop %sh{
+ kitty @ send-text -m=title:kak_repl_window "${kak_selection}"
}
}