2016-07-25 13:22:32 +03:00
|
|
|
# https://www.iterm2.com
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
## The default behaviour for the `new` command is to open an vertical pane in
|
|
|
|
## an iTerm session if not in a tmux session.
|
|
|
|
hook global KakBegin .* %{
|
|
|
|
%sh{
|
|
|
|
if [ "$TERM_PROGRAM" = "iTerm.app" -a -z "$TMUX" ]; then
|
|
|
|
echo "
|
|
|
|
alias global new iterm-new-vertical
|
|
|
|
alias global focus iterm-focus
|
|
|
|
"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden -params 1.. iterm-new-split-impl %{
|
2016-07-25 13:22:32 +03:00
|
|
|
%sh{
|
|
|
|
direction="$1"
|
|
|
|
shift
|
|
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
2017-04-10 22:17:59 +03:00
|
|
|
osascript \
|
|
|
|
-e "tell application \"iTerm\"" \
|
|
|
|
-e " tell current session of current window" \
|
|
|
|
-e " tell (split ${direction} with same profile)" \
|
|
|
|
-e " select" \
|
2017-10-13 22:24:52 +03:00
|
|
|
-e " write text \"export TMPDIR='${TMPDIR}'\"" \
|
|
|
|
-e " write text \"exec ${sh_cmd}\"" \
|
2017-04-10 22:17:59 +03:00
|
|
|
-e " end tell" \
|
|
|
|
-e " end tell" \
|
2016-07-25 13:22:32 +03:00
|
|
|
-e "end tell"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command iterm-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
|
2016-07-25 13:22:32 +03:00
|
|
|
iterm-new-split-impl 'vertically' %arg{@}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command iterm-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
|
2016-07-25 13:22:32 +03:00
|
|
|
iterm-new-split-impl 'horizontally' %arg{@}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -params .. -command-completion \
|
2016-10-11 10:03:41 +03:00
|
|
|
-docstring %{iterm-new-tab [<arguments>]: create a new tab
|
|
|
|
All optional arguments are forwarded to the new kak client} \
|
|
|
|
iterm-new-tab %{
|
2016-07-25 13:22:32 +03:00
|
|
|
%sh{
|
|
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
|
|
|
osascript \
|
|
|
|
-e "tell application \"iTerm\"" \
|
|
|
|
-e " tell current window" \
|
|
|
|
-e " tell current session of (create tab with default profile)" \
|
2017-10-13 22:24:52 +03:00
|
|
|
-e " write text \"export TMPDIR='${TMPDIR}'\"" \
|
|
|
|
-e " write text \"exec ${sh_cmd}\"" \
|
2016-07-25 13:22:32 +03:00
|
|
|
-e " end tell" \
|
|
|
|
-e " end tell" \
|
|
|
|
-e "end tell"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -params .. -command-completion \
|
2016-10-11 10:03:41 +03:00
|
|
|
-docstring %{iterm-new-window [<arguments>]: create a new window
|
|
|
|
All optional arguments are forwarded to the new kak client} \
|
|
|
|
iterm-new-window %{
|
2016-07-25 13:22:32 +03:00
|
|
|
%sh{
|
|
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
2017-04-10 22:17:59 +03:00
|
|
|
osascript \
|
|
|
|
-e "tell application \"iTerm\"" \
|
2017-11-03 10:34:41 +03:00
|
|
|
-e " set-option w to (create window with default profile)" \
|
2017-04-10 22:17:59 +03:00
|
|
|
-e " tell current session of w" \
|
2017-10-13 22:24:52 +03:00
|
|
|
-e " write text \"export TMPDIR='${TMPDIR}'\"" \
|
|
|
|
-e " write text \"exec ${sh_cmd}\"" \
|
2017-04-10 22:17:59 +03:00
|
|
|
-e " end tell" \
|
2016-07-25 13:22:32 +03:00
|
|
|
-e "end tell"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -params ..1 -client-completion \
|
2016-10-11 10:03:41 +03:00
|
|
|
-docstring %{iterm-focus [<client>]: focus the given client
|
|
|
|
If no client is passed then the current one is used} \
|
|
|
|
iterm-focus %{
|
2016-07-25 13:22:32 +03:00
|
|
|
# Should be possible using ${kak_client_env_ITERM_SESSION_ID}.
|
2017-07-19 18:18:52 +03:00
|
|
|
%sh{echo "echo -markup '{Error}Not implemented yet for iTerm'"}
|
2016-07-25 13:22:32 +03:00
|
|
|
}
|