Merge remote-tracking branch 'lenormf/rc/tmux.kak'
This commit is contained in:
commit
c6e1d9b3dd
|
@ -1,9 +1,6 @@
|
||||||
# termcmd should be set such as the next argument is the whole
|
# termcmd should be set such as the next argument is the whole
|
||||||
# command line to execute
|
# command line to execute
|
||||||
decl str termcmd %sh{
|
decl str termcmd %sh{
|
||||||
if [ -n "$TMUX" ]; then
|
|
||||||
echo "'tmux split-window -h'"
|
|
||||||
else
|
|
||||||
for termcmd in 'termite -e ' \
|
for termcmd in 'termite -e ' \
|
||||||
'urxvt -e sh -c' \
|
'urxvt -e sh -c' \
|
||||||
'rxvt -e sh -c' \
|
'rxvt -e sh -c' \
|
||||||
|
@ -19,7 +16,6 @@ decl str termcmd %sh{
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def -docstring 'create a new kak client for current session' \
|
def -docstring 'create a new kak client for current session' \
|
||||||
|
@ -36,16 +32,14 @@ def -docstring 'create a new kak client for current session' \
|
||||||
|
|
||||||
def -docstring 'focus given client' \
|
def -docstring 'focus given client' \
|
||||||
-shell-params -client-completion \
|
-shell-params -client-completion \
|
||||||
focus %{ %sh{
|
focus-default %{ %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
|
|
||||||
if [ -n "$kak_client_env_TMUX" ]; then
|
|
||||||
TMUX="$kak_client_env_TMUX" tmux select-pane -t "$kak_client_env_TMUX_PANE" > /dev/null
|
|
||||||
else
|
else
|
||||||
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
} }
|
} }
|
||||||
|
## Create an alias to the default focus callback to allow overriding from custom scripts (i.e. tmux)
|
||||||
|
alias global focus focus-default
|
||||||
|
|
71
rc/tmux.kak
Normal file
71
rc/tmux.kak
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
# 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
|
||||||
|
hook global KakBegin .* %{
|
||||||
|
%sh{
|
||||||
|
if [ -n "$TMUX" ]; then
|
||||||
|
tmuxcmd=""
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
## Temporarily override the default client creation command
|
||||||
|
def -hidden -shell-params tmux_override_termcmd %{
|
||||||
|
%sh{
|
||||||
|
if [ -z "$TMUX" ]; then
|
||||||
|
echo "echo -color Error This command is only available in a tmux session"
|
||||||
|
else
|
||||||
|
readonly cmd_override="$1"
|
||||||
|
readonly termcmd="${kak_opt_termcmd}"
|
||||||
|
|
||||||
|
shift
|
||||||
|
echo "
|
||||||
|
set current termcmd '${cmd_override}'
|
||||||
|
eval new $@
|
||||||
|
set current termcmd '${termcmd//'/\\'}'
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def tmux-new-vertical -shell-params -command-completion -docstring "Create a new vertical pane in tmux" %{
|
||||||
|
%sh{
|
||||||
|
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" %{
|
||||||
|
%sh{
|
||||||
|
echo "eval %{tmux_override_termcmd 'tmux split-window -h' $@}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def -docstring "focus given client" \
|
||||||
|
-shell-params -client-completion \
|
||||||
|
focus-tmux %{ %sh{
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
echo "echo -color Error 'too many arguments, use focus [client]'"
|
||||||
|
elif [ $# -eq 1 ]; then
|
||||||
|
echo "eval -client '$1' focus"
|
||||||
|
elif [ -n "${kak_client_env_TMUX}" ]; then
|
||||||
|
TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null
|
||||||
|
fi
|
||||||
|
} }
|
Loading…
Reference in New Issue
Block a user