This repository has been archived by the owner on Jun 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
dvtm.kak
62 lines (55 loc) · 2.13 KB
/
dvtm.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
##
## dvtm.kak by lenormf
## Support for client creation/tagging/focusing from a kakoune client
##
# http://www.brain-dump.org/projects/dvtm/
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global KakBegin .* %{
evaluate-commands %sh{
if [ -n "${DVTM}" ]; then
echo "
alias global new dvtm-new-window
alias global focus dvtm-focus
"
fi
}
}
define-command -params .. -command-completion -docstring "Create a new window" \
dvtm-new-window %{ evaluate-commands %sh{
params=""
if [ $# -gt 0 ]; then
## `dvtm` requires those simple quotes to be escaped even within double quotes
params="-e \\'$@\\'"
fi
## The FIFO command pipe has to be created using the `-c` flag
if [ -p "${DVTM_CMD_FIFO}" ]; then
printf %s\\n "create \"kak -c ${kak_session} ${params}\"" > "${DVTM_CMD_FIFO}"
else
printf %s\\n 'echo -color Error No command socket available'
fi
} }
define-command -params 0..1 -client-completion -docstring %{dvtm-focus [<client>] focus a client
If no client is passed, then the current client is used} \
dvtm-focus %{ evaluate-commands %sh{
if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus"
elif [ -p "${DVTM_CMD_FIFO}" ]; then
printf %s\\n "focus ${kak_client_env_DVTM_WINDOW_ID}" > "${DVTM_CMD_FIFO}"
else
printf %s\\n "echo -color Error No command socket available"
fi
} }
define-command -params 1.. -docstring %{dvtm-cmd <command> <args>: interact with dvtm using the dvtm-cmd utility
The command argument is a command supported by dvtm-cmd
The tags arguments is a list of one or more tags to assign to the given client} \
dvtm-cmd %{ evaluate-commands %sh{
if [ -p "${DVTM_CMD_FIFO}" ]; then
readonly command="$1"; shift
readonly output=$(dvtm-cmd "${command}" "$@" 2>&1)
if [ -n "${output}" ]; then
printf %s\\n "echo -color Error %{ ${output} }"
fi
else
printf %s\\n "echo -color Error No command socket available"
fi
} }