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
/
Copy pathhatch_terminal.kak
50 lines (46 loc) · 2.05 KB
/
hatch_terminal.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
##
## hatch_terminal.kak by lenormf
## Spawn a new shell/command whose environment contains Kakoune metadata
##
define-command hatch-terminal-x11 -params .. -docstring %{
hatch-terminal-x11 [command]: open a new X11 terminal
If specified, the command will be ran in the newly created terminal, otherwise a shell is spawned
The environment contains the `KAK_SESSION` variable set to the parent session's name
} %{ evaluate-commands %sh{
setsid ${kak_opt_termcmd} "env TMPDIR='${TMPDIR}' \
KAK_SESSION='${kak_session}' \
KAK_CLIENT='${kak_client}' \
${*:-${SHELL}}" </dev/null >/dev/null 2>&1 &
} }
define-command hatch-terminal-tmux -params .. -docstring %{
hatch-terminal-tmux [command]: open a new `tmux` horizontal pane
If specified, the command will be ran in the newly created terminal, otherwise a shell is spawned
The environment contains the `KAK_SESSION` variable set to the parent session's name
} %{ evaluate-commands %sh{
env TMUX="${kak_client_env_TMUX:-${TMUX}}" tmux split-window -h \
"env TMPDIR='${TMPDIR}' \
KAK_SESSION='${kak_session}' \
KAK_CLIENT='${kak_client}' \
${*:-${SHELL}}" </dev/null >/dev/null 2>&1 &
} }
define-command hatch-terminal-dvtm -params .. -docstring %{
hatch-terminal-dvtm [command]: open a new `dvtm` pane
If specified, the command will be ran in the newly created terminal, otherwise a shell is spawned
The environment contains the `KAK_SESSION` variable set to the parent session's name
} %{ evaluate-commands %sh{
if [ -p "${DVTM_CMD_FIFO}" ]; then
printf %s\\n "create \"env TMPDIR='${TMPDIR}' \
KAK_SESSION='${kak_session}' \
KAK_CLIENT='${kak_client}' \
${*:-${SHELL}}\"" > "${DVTM_CMD_FIFO}"
fi
} }
evaluate-commands %sh{
if [ -n "${TMUX}" ]; then
echo "alias global hatch-terminal hatch-terminal-tmux"
elif [ -n "${DVTM}" ]; then
echo "alias global hatch-terminal hatch-terminal-dvtm"
elif [ -n "${DISPLAY}" ]; then
echo "alias global hatch-terminal hatch-terminal-x11"
fi
}