Move client.kak as x11.kak and change tmux.kak to be its peer
This commit is contained in:
parent
cb108b248a
commit
208b91627d
51
rc/tmux.kak
51
rc/tmux.kak
|
@ -1,66 +1,45 @@
|
||||||
# http://tmux.github.io/
|
# http://tmux.github.io/
|
||||||
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
## Can be one of "horizontal", "vertical" or "window"
|
|
||||||
## When a new client is created, an horizontal pane, a vertical pane or a window will respectively be made
|
|
||||||
decl str tmux_default_direction "horizontal"
|
|
||||||
|
|
||||||
## The default behaviour for the `new` command is to open an horizontal pane in a tmux session
|
## The default behaviour for the `new` command is to open an horizontal pane in a tmux session
|
||||||
hook global KakBegin .* %{
|
hook global KakBegin .* %{
|
||||||
%sh{
|
%sh{
|
||||||
if [ -n "$TMUX" ]; then
|
if [ -n "$TMUX" ]; then
|
||||||
tmuxcmd=""
|
echo "alias global focus tmux-focus"
|
||||||
|
echo "alias global new tmux-new-horizontal"
|
||||||
case "${kak_opt_tmux_default_direction}" in
|
|
||||||
vertical) tmuxcmd="tmux split-window -v";;
|
|
||||||
window) tmuxcmd="tmux new-window";;
|
|
||||||
horizontal) tmuxcmd="tmux split-window -h";;
|
|
||||||
*) echo "invalid value: ${kak_opt_tmux_default_direction}" >&2;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -n "${tmuxcmd}" ]; then
|
|
||||||
echo "set global termcmd '${tmuxcmd}'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "alias global focus focus-tmux"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## Temporarily override the default client creation command
|
## Temporarily override the default client creation command
|
||||||
def -hidden -shell-params tmux_override_termcmd %{
|
def -hidden -shell-params tmux-new-impl %{
|
||||||
%sh{
|
%sh{
|
||||||
if [ -z "$TMUX" ]; then
|
if [ -z "$TMUX" ]; then
|
||||||
echo "echo -color Error This command is only available in a tmux session"
|
echo "echo -color Error This command is only available in a tmux session"
|
||||||
else
|
exit
|
||||||
readonly cmd_override="$1"
|
|
||||||
readonly termcmd="${kak_opt_termcmd}"
|
|
||||||
|
|
||||||
shift
|
|
||||||
echo "
|
|
||||||
set current termcmd '${cmd_override}'
|
|
||||||
eval new $@
|
|
||||||
set current termcmd '${termcmd//'/\\'}'
|
|
||||||
"
|
|
||||||
fi
|
fi
|
||||||
|
tmux_args="$1"
|
||||||
|
shift
|
||||||
|
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
|
||||||
|
tmux $tmux_args "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def tmux-new-vertical -shell-params -command-completion -docstring "Create a new vertical pane in tmux" %{
|
def tmux-new-vertical -shell-params -command-completion -docstring "Create a new vertical pane in tmux" %{
|
||||||
%sh{
|
%sh{ echo "tmux-new-impl 'split-window -v' $@" }
|
||||||
echo "eval %{tmux_override_termcmd 'tmux split-window -v' $@}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def tmux-new-horizontal -shell-params -command-completion -docstring "Create a new horizontal pane in tmux" %{
|
def tmux-new-horizontal -shell-params -command-completion -docstring "Create a new horizontal pane in tmux" %{
|
||||||
%sh{
|
%sh{ echo "tmux-new-impl 'split-window -h' $@" }
|
||||||
echo "eval %{tmux_override_termcmd 'tmux split-window -h' $@}"
|
}
|
||||||
}
|
|
||||||
|
def tmux-new-window -shell-params -command-completion -docstring "Create a new horizontal pane in tmux" %{
|
||||||
|
%sh{ echo "tmux-new-impl 'new-window' $@" }
|
||||||
}
|
}
|
||||||
|
|
||||||
def -docstring "focus given client" \
|
def -docstring "focus given client" \
|
||||||
-shell-params -client-completion \
|
-shell-params -client-completion \
|
||||||
focus-tmux %{ %sh{
|
tmux-focus %{ %sh{
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
echo "echo -color Error 'too many arguments, use focus [client]'"
|
echo "echo -color Error 'too many arguments, use focus [client]'"
|
||||||
elif [ $# -eq 1 ]; then
|
elif [ $# -eq 1 ]; then
|
||||||
|
|
|
@ -21,7 +21,7 @@ decl str termcmd %sh{
|
||||||
def -docstring 'create a new kak client for current session' \
|
def -docstring 'create a new kak client for current session' \
|
||||||
-shell-params \
|
-shell-params \
|
||||||
-command-completion \
|
-command-completion \
|
||||||
new %{ %sh{
|
x11-new %{ %sh{
|
||||||
if [ -z "${kak_opt_termcmd}" ]; then
|
if [ -z "${kak_opt_termcmd}" ]; then
|
||||||
echo "echo -color Error 'termcmd option is not set'"
|
echo "echo -color Error 'termcmd option is not set'"
|
||||||
exit
|
exit
|
||||||
|
@ -30,16 +30,17 @@ def -docstring 'create a new kak client for current session' \
|
||||||
setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
||||||
}}
|
}}
|
||||||
|
|
||||||
def -docstring 'focus given client' \
|
def -docstring 'focus given client\'s window' \
|
||||||
-shell-params -client-completion \
|
-shell-params -client-completion \
|
||||||
focus-default %{ %sh{
|
x11-focus %{ %sh{
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
echo "echo -color Error 'too many arguments, use focus [client]'"
|
echo "echo -color Error 'too many arguments, use focus [client]'"
|
||||||
elif [ $# -eq 1 ]; then
|
elif [ $# -eq 1 ]; then
|
||||||
echo "eval -client '$1' focus"
|
echo "eval -client '$1' focus"
|
||||||
else
|
else
|
||||||
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
||||||
fi
|
fi
|
||||||
} }
|
} }
|
||||||
## Create an alias to the default focus callback to allow overriding from custom scripts (i.e. tmux)
|
|
||||||
alias global focus focus-default
|
alias global focus x11-focus
|
||||||
|
alias global new x11-new
|
Loading…
Reference in New Issue
Block a user