mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-26 13:02:01 +03:00
f6a2925950
Level out the builtin commands loaded at startup in terms of format and expressiveness. The following convention was followed: * commands that take more than one argument have to be described along with their parameters prior to the actual documentation, otherwise the docstring consists in a capitalized sentence e.g. `command <arg1>: do something` * optional arguments are enclosed in square brackets, to comply with the format used for hardcoded commands e.g. `cd [<directory>]` * describe the effects of the command in the documentation string and omit implementation details unless they are relevant. Usually command names include the name of the tool they use, so they don't need to be redundantly mentioned e.g. `tmux-new-pane <arguments>: open a new pane` * document the format the parameters to the commands, or list them if they are to be chosen among a list of static values (c.f. `spell.kak`)
53 lines
1.7 KiB
Plaintext
53 lines
1.7 KiB
Plaintext
# 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
|
|
echo "
|
|
alias global focus tmux-focus
|
|
alias global new tmux-new-horizontal
|
|
"
|
|
fi
|
|
}
|
|
}
|
|
|
|
## Temporarily override the default client creation command
|
|
def -hidden -params 1.. tmux-new-impl %{
|
|
%sh{
|
|
tmux=${kak_client_env_TMUX:-$TMUX}
|
|
if [ -z "$tmux" ]; then
|
|
echo "echo -color Error 'This command is only available in a tmux session'"
|
|
exit
|
|
fi
|
|
tmux_args="$1"
|
|
shift
|
|
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
|
|
TMUX=$tmux tmux $tmux_args "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
|
|
}
|
|
}
|
|
|
|
def tmux-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
|
|
tmux-new-impl 'split-window -v' %arg{@}
|
|
}
|
|
|
|
def tmux-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
|
|
tmux-new-impl 'split-window -h' %arg{@}
|
|
}
|
|
|
|
def tmux-new-window -params .. -command-completion -docstring "Create a new window" %{
|
|
tmux-new-impl 'new-window' %arg{@}
|
|
}
|
|
|
|
def -docstring %{tmux-focus [<client>]: focus the given client
|
|
If no client is passed then the current one is used} \
|
|
-params ..1 -client-completion \
|
|
tmux-focus %{ %sh{
|
|
if [ $# -eq 1 ]; then
|
|
printf %s\\n "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
|
|
} }
|