Attempt to create iterm-terminal commands

This commit is contained in:
Olivier Perret 2018-12-03 19:53:30 +01:00
parent 74d1dc756a
commit 84da1911be

View File

@ -12,12 +12,10 @@ hook global KakBegin .* %sh{
fi fi
} }
define-command -hidden -params 1.. iterm-new-split-impl %{ define-command -hidden -params 2 iterm-terminal-split-impl %{
nop %sh{ nop %sh{
direction="$1" direction="$1"
shift cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' sh -c '$2'"
if [ $# -gt 0 ]; then kakoune_params="-e \\\"$*\\\""; fi
cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' kak -c '${kak_session}' ${kakoune_params}"
osascript \ osascript \
-e "tell application \"iTerm\"" \ -e "tell application \"iTerm\"" \
-e " tell current session of current window" \ -e " tell current session of current window" \
@ -27,21 +25,27 @@ define-command -hidden -params 1.. iterm-new-split-impl %{
} }
} }
define-command iterm-new-vertical -params .. -command-completion -docstring "Split the current pane into two, top and bottom" %{ define-command iterm-terminal-vertical -params 1 -shell-completion -docstring '
iterm-new-split-impl 'vertically' %arg{@} iterm-terminal-vertical <program>: create a new terminal as an iterm pane
The current pane is split into two, top and bottom
The shell program passed as argument will be executed in the new terminal'\
%{
iterm-terminal-split-impl 'vertically' %arg{1}
}
define-command iterm-terminal-horizontal -params 1 -shell-completion -docstring '
iterm-terminal-horizontal <program>: create a new terminal as an iterm pane
The current pane is split into two, left and right
The shell program passed as argument will be executed in the new terminal'\
%{
iterm-terminal-split-impl 'horizontally' %arg{1}
} }
define-command iterm-new-horizontal -params .. -command-completion -docstring "Split the current pane into two, left and right" %{ define-command iterm-terminal-tab -params 1 -shell-completion -docstring '
iterm-new-split-impl 'horizontally' %arg{@} iterm-terminal-tab <program>: create a new terminal as an iterm tab
} The shell program passed as argument will be executed in the new terminal'\
%{
define-command -params .. -command-completion \
-docstring %{iterm-new-tab [<arguments>]: create a new tab
All optional arguments are forwarded to the new kak client} \
iterm-new-tab %{
nop %sh{ nop %sh{
if [ $# -gt 0 ]; then kakoune_params="-e \\\"$*\\\""; fi cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' sh -c '$1'"
cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' kak -c '${kak_session}' ${kakoune_params}"
osascript \ osascript \
-e "tell application \"iTerm\"" \ -e "tell application \"iTerm\"" \
-e " tell current window" \ -e " tell current window" \
@ -51,13 +55,12 @@ All optional arguments are forwarded to the new kak client} \
} }
} }
define-command -params .. -command-completion \ define-command iterm-terminal-window -params 1 -shell-completion -docstring '
-docstring %{iterm-new-window [<arguments>]: create a new window iterm-terminal-window <program>: create a new terminal as an iterm window
All optional arguments are forwarded to the new kak client} \ The shell program passed as argument will be executed in the new terminal'\
iterm-new-window %{ %{
nop %sh{ nop %sh{
if [ $# -gt 0 ]; then kakoune_params="-e \\\"$*\\\""; fi cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' sh -c '$1'"
cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' kak -c '${kak_session}' ${kakoune_params}"
osascript \ osascript \
-e "tell application \"iTerm\"" \ -e "tell application \"iTerm\"" \
-e " create window with default profile command \"${cmd}\"" \ -e " create window with default profile command \"${cmd}\"" \
@ -65,10 +68,38 @@ All optional arguments are forwarded to the new kak client} \
} }
} }
define-command -params ..1 -client-completion \ define-command iterm-new-vertical -params .. -command-completion -docstring '
-docstring %{iterm-focus [<client>]: focus the given client iterm-new-vertical <program>: create a new kakoune client as an iterm pane
If no client is passed then the current one is used} \ The current pane is split into two, top and bottom
iterm-focus %{ evaluate-commands %sh{ The optional arguments are passed as commands to the new client' \
%{
iterm-terminal-vertical "kak -c %val{session} -e '%arg{@}'"
}
define-command iterm-new-horizontal -params .. -command-completion -docstring '
iterm-new-horizontal <program>: create a new kakoune client as an iterm pane
The current pane is split into two, left and right
The optional arguments are passed as commands to the new client' \
%{
iterm-terminal-horizontal "kak -c %val{session} -e '%arg{@}'"
}
define-command iterm-new-tab -params .. -command-completion -docstring '
iterm-new-tab <program>: create a new kakoune client as an iterm tab
The optional arguments are passed as commands to the new client' \
%{
iterm-terminal-tab "kak -c %val{session} -e '%arg{@}'"
}
define-command iterm-new-window -params .. -command-completion -docstring '
iterm-new-window <program>: create a new kakoune client as an iterm window
The optional arguments are passed as commands to the new client' \
%{
iterm-terminal-window "kak -c %val{session} -e '%arg{@}'"
}
define-command iterm-focus -params ..1 -client-completion -docstring '
iterm-focus [<client>]: focus the given client
If no client is passed then the current one is used' \
%{
evaluate-commands %sh{
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
printf %s\\n "evaluate-commands -client '$1' focus" printf %s\\n "evaluate-commands -client '$1' focus"
else else