Skip to content
This repository has been archived by the owner on Jun 20, 2020. It is now read-only.

Add the new(ish) :terminal command for dvtm. #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions dvtm.kak
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ hook global KakBegin .* %{
evaluate-commands %sh{
if [ -n "${DVTM}" ]; then
echo "
alias global new dvtm-new-window
alias global terminal dvtm-terminal
alias global focus dvtm-focus
alias global new dvtm-new
"
fi
}
}

define-command -params 1.. -shell-completion -docstring "Create a new terminal
and launch any arguments as a command in it." \
dvtm-terminal %{ nop %sh{
if [ -p "${DVTM_CMD_FIFO}" ]; then
printf %s\\n "create \"$@\"" > "${DVTM_CMD_FIFO}"
else
printf %s\\n 'echo Error No command socket available'
fi
} }

define-command -params .. -command-completion -docstring "Create a new window" \
dvtm-new-window %{ evaluate-commands %sh{
dvtm-new %{ evaluate-commands %sh{
params=""
if [ $# -gt 0 ]; then
## `dvtm` requires those simple quotes to be escaped even within double quotes
Expand All @@ -29,7 +40,7 @@ define-command -params .. -command-completion -docstring "Create a new window" \
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'
printf %s\\n 'echo Error No command socket available'
fi
} }

Expand All @@ -41,7 +52,7 @@ If no client is passed, then the current client is used} \
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"
printf %s\\n "echo Error No command socket available"
fi
} }

Expand All @@ -57,6 +68,6 @@ The tags arguments is a list of one or more tags to assign to the given client}
printf %s\\n "echo -color Error %{ ${output} }"
fi
else
printf %s\\n "echo -color Error No command socket available"
printf %s\\n "echo Error No command socket available"
fi
} }