-
Notifications
You must be signed in to change notification settings - Fork 715
/
kitty.kak
84 lines (69 loc) · 2.67 KB
/
kitty.kak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# https://sw.kovidgoyal.net/kitty/index.html
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
provide-module kitty %{
# ensure that we're running on kitty
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 (window|os-window)} str kitty_window_type window
define-command kitty-terminal-window -params 1.. -docstring '
kitty-terminal-window <program> [<arguments>]: create a new terminal as a kitty window
The program passed as argument will be executed in the new terminal' \
%{
nop %sh{
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 --type="$kak_opt_kitty_window_type" --cwd="$PWD" $match "$@"
}
}
complete-command kitty-terminal-window shell
define-command kitty-terminal-tab -params 1.. -docstring '
kitty-terminal-tab <program> [<arguments>]: create a new terminal as kitty tab
The program passed as argument will be executed in the new terminal' \
%{
nop %sh{
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 --type=tab --cwd="$PWD" $match "$@"
}
}
complete-command kitty-terminal-tab shell
define-command kitty-focus -params ..1 -docstring '
kitty-focus [<client>]: focus the given client
If no client is passed then the current one is used' \
%{
evaluate-commands %sh{
if [ $# -eq 1 ]; then
printf "evaluate-commands -client '%s' focus" "$1"
else
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
}
}
complete-command -menu kitty-focus client
alias global focus kitty-focus
# deprecated
define-command -hidden kitty-terminal -params 1.. %{
kitty-terminal-window %arg{@}
}
}