mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-28 06:08:05 +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`)
85 lines
3.4 KiB
Plaintext
85 lines
3.4 KiB
Plaintext
# https://www.iterm2.com
|
|
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
|
|
|
## The default behaviour for the `new` command is to open an vertical pane in
|
|
## an iTerm session if not in a tmux session.
|
|
hook global KakBegin .* %{
|
|
%sh{
|
|
if [ "$TERM_PROGRAM" = "iTerm.app" -a -z "$TMUX" ]; then
|
|
echo "
|
|
alias global new iterm-new-vertical
|
|
alias global focus iterm-focus
|
|
"
|
|
fi
|
|
}
|
|
}
|
|
|
|
def -hidden -params 1.. iterm-new-split-impl %{
|
|
%sh{
|
|
direction="$1"
|
|
shift
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
|
osascript \
|
|
-e "tell application \"iTerm\"" \
|
|
-e " tell current session of current window" \
|
|
-e " tell (split ${direction} with same profile)" \
|
|
-e " select" \
|
|
-e " write text \"${sh_cmd}\"" \
|
|
-e " end tell" \
|
|
-e " end tell" \
|
|
-e "end tell"
|
|
}
|
|
}
|
|
|
|
def iterm-new-vertical -params .. -command-completion -docstring "Create a new vertical pane" %{
|
|
iterm-new-split-impl 'vertically' %arg{@}
|
|
}
|
|
|
|
def iterm-new-horizontal -params .. -command-completion -docstring "Create a new horizontal pane" %{
|
|
iterm-new-split-impl 'horizontally' %arg{@}
|
|
}
|
|
|
|
def -params .. -command-completion \
|
|
-docstring %{iterm-new-tab [<arguments>]: create a new tab
|
|
All optional arguments are forwarded to the new kak client} \
|
|
iterm-new-tab %{
|
|
%sh{
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
|
osascript \
|
|
-e "tell application \"iTerm\"" \
|
|
-e " tell current window" \
|
|
-e " tell current session of (create tab with default profile)" \
|
|
-e " write text \"${sh_cmd}\"" \
|
|
-e " end tell" \
|
|
-e " end tell" \
|
|
-e "end tell"
|
|
}
|
|
}
|
|
|
|
def -params .. -command-completion \
|
|
-docstring %{iterm-new-window [<arguments>]: create a new window
|
|
All optional arguments are forwarded to the new kak client} \
|
|
iterm-new-window %{
|
|
%sh{
|
|
if [ $# -gt 0 ]; then kakoune_params="-e '$@'"; fi
|
|
sh_cmd="kak -c ${kak_session} ${kakoune_params}"
|
|
osascript \
|
|
-e "tell application \"iTerm\"" \
|
|
-e " set w to (create window with default profile)" \
|
|
-e " tell current session of w" \
|
|
-e " write text \"${sh_cmd}\"" \
|
|
-e " end tell" \
|
|
-e "end tell"
|
|
}
|
|
}
|
|
|
|
def -params ..1 -client-completion \
|
|
-docstring %{iterm-focus [<client>]: focus the given client
|
|
If no client is passed then the current one is used} \
|
|
iterm-focus %{
|
|
# Should be possible using ${kak_client_env_ITERM_SESSION_ID}.
|
|
%sh{echo "echo -color Error 'Not implemented yet for iTerm'"}
|
|
}
|