2015-11-06 10:13:19 +03:00
|
|
|
# http://tmux.github.io/
|
|
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
|
|
|
|
## The default behaviour for the `new` command is to open an horizontal pane in a tmux session
|
2018-05-07 00:29:52 +03:00
|
|
|
hook global KakBegin .* %sh{
|
|
|
|
if [ -n "$TMUX" ]; then
|
|
|
|
echo "
|
|
|
|
alias global focus tmux-focus
|
|
|
|
alias global new tmux-new-horizontal
|
|
|
|
"
|
|
|
|
fi
|
2015-11-06 10:13:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
## Temporarily override the default client creation command
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -hidden -params 1.. tmux-new-impl %{
|
2018-05-07 00:29:52 +03:00
|
|
|
evaluate-commands %sh{
|
2016-05-05 15:32:16 +03:00
|
|
|
tmux=${kak_client_env_TMUX:-$TMUX}
|
|
|
|
if [ -z "$tmux" ]; then
|
2017-07-19 18:18:52 +03:00
|
|
|
echo "echo -markup '{Error}This command is only available in a tmux session'"
|
2015-11-18 01:25:33 +03:00
|
|
|
exit
|
2015-11-06 10:13:19 +03:00
|
|
|
fi
|
2015-11-18 01:25:33 +03:00
|
|
|
tmux_args="$1"
|
|
|
|
shift
|
|
|
|
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
|
2017-04-17 22:55:37 +03:00
|
|
|
TMUX=$tmux tmux $tmux_args "env TMPDIR='${TMPDIR}' kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
2015-11-06 10:13:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-30 14:17:46 +03:00
|
|
|
define-command tmux-new-vertical -params .. -command-completion -docstring "Split the current pane into two, top and bottom" %{
|
2015-12-02 03:53:34 +03:00
|
|
|
tmux-new-impl 'split-window -v' %arg{@}
|
2015-11-06 10:13:19 +03:00
|
|
|
}
|
|
|
|
|
2018-06-30 14:17:46 +03:00
|
|
|
define-command tmux-new-horizontal -params .. -command-completion -docstring "Split the current pane into two, left and right" %{
|
2015-12-02 03:53:34 +03:00
|
|
|
tmux-new-impl 'split-window -h' %arg{@}
|
2015-11-18 01:25:33 +03:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command tmux-new-window -params .. -command-completion -docstring "Create a new window" %{
|
2015-12-02 03:53:34 +03:00
|
|
|
tmux-new-impl 'new-window' %arg{@}
|
2015-11-06 10:13:19 +03:00
|
|
|
}
|
|
|
|
|
2017-11-03 10:34:41 +03:00
|
|
|
define-command -docstring %{tmux-focus [<client>]: focus the given client
|
2016-10-11 10:03:41 +03:00
|
|
|
If no client is passed then the current one is used} \
|
|
|
|
-params ..1 -client-completion \
|
2018-05-07 00:29:52 +03:00
|
|
|
tmux-focus %{ evaluate-commands %sh{
|
2016-10-11 10:03:41 +03:00
|
|
|
if [ $# -eq 1 ]; then
|
2017-11-03 11:09:45 +03:00
|
|
|
printf %s\\n "evaluate-commands -client '$1' focus"
|
2015-11-06 10:13:19 +03: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
|
|
|
|
} }
|