2015-11-06 08:13:19 +01:00
|
|
|
# http://tmux.github.io/
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
## The default behaviour for the `new` command is to open an horizontal pane in a tmux session
|
|
|
|
hook global KakBegin .* %{
|
|
|
|
%sh{
|
|
|
|
if [ -n "$TMUX" ]; then
|
2016-04-23 07:47:01 +02:00
|
|
|
echo "
|
|
|
|
alias global focus tmux-focus
|
|
|
|
alias global new tmux-new-horizontal
|
|
|
|
"
|
2015-11-06 08:13:19 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## Temporarily override the default client creation command
|
2015-12-01 15:00:55 +01:00
|
|
|
def -hidden -params 1.. tmux-new-impl %{
|
2015-11-06 08:13:19 +01:00
|
|
|
%sh{
|
2016-05-05 14:32:16 +02:00
|
|
|
tmux=${kak_client_env_TMUX:-$TMUX}
|
|
|
|
if [ -z "$tmux" ]; then
|
2016-04-23 07:47:01 +02:00
|
|
|
echo "echo -color Error 'This command is only available in a tmux session'"
|
2015-11-17 23:25:33 +01:00
|
|
|
exit
|
2015-11-06 08:13:19 +01:00
|
|
|
fi
|
2015-11-17 23:25:33 +01:00
|
|
|
tmux_args="$1"
|
|
|
|
shift
|
|
|
|
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
|
2017-04-09 08:16:56 +02:00
|
|
|
TMUX=$tmux tmux $tmux_args "TMPDIR='${TMPDIR}' kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
2015-11-06 08:13:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-11 09:03:41 +02:00
|
|
|
def tmux-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
|
2015-12-02 01:53:34 +01:00
|
|
|
tmux-new-impl 'split-window -v' %arg{@}
|
2015-11-06 08:13:19 +01:00
|
|
|
}
|
|
|
|
|
2016-10-11 09:03:41 +02:00
|
|
|
def tmux-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
|
2015-12-02 01:53:34 +01:00
|
|
|
tmux-new-impl 'split-window -h' %arg{@}
|
2015-11-17 23:25:33 +01:00
|
|
|
}
|
|
|
|
|
2016-10-11 09:03:41 +02:00
|
|
|
def tmux-new-window -params .. -command-completion -docstring "Create a new window" %{
|
2015-12-02 01:53:34 +01:00
|
|
|
tmux-new-impl 'new-window' %arg{@}
|
2015-11-06 08:13:19 +01:00
|
|
|
}
|
|
|
|
|
2016-10-11 09:03:41 +02:00
|
|
|
def -docstring %{tmux-focus [<client>]: focus the given client
|
|
|
|
If no client is passed then the current one is used} \
|
|
|
|
-params ..1 -client-completion \
|
2015-11-17 23:25:33 +01:00
|
|
|
tmux-focus %{ %sh{
|
2016-10-11 09:03:41 +02:00
|
|
|
if [ $# -eq 1 ]; then
|
2016-04-23 07:47:01 +02:00
|
|
|
printf %s\\n "eval -client '$1' focus"
|
2015-11-06 08:13:19 +01:00
|
|
|
elif [ -n "${kak_client_env_TMUX}" ]; then
|
|
|
|
TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null
|
|
|
|
fi
|
|
|
|
} }
|