home/rc/base/x11.kak
Frank LENORMAND f6a2925950 Fix, complete and add docstring documentation to builtin commands
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`)
2016-10-11 10:26:17 +03:00

47 lines
1.6 KiB
Plaintext

# termcmd should be set such as the next argument is the whole
# command line to execute
decl str termcmd %sh{
for termcmd in 'termite -e ' \
'urxvt -e sh -c' \
'rxvt -e sh -c' \
'xterm -e sh -c' \
'roxterm -e sh -c' \
'mintty -e sh -c' \
'sakura -e ' \
'gnome-terminal -e ' \
'xfce4-terminal -e ' ; do
terminal=${termcmd%% *}
if which $terminal > /dev/null 2>&1; then
printf %s\\n "'$termcmd'"
exit
fi
done
}
def -docstring %{x11-new [<command>]: create a new kak client for the current session
The optional arguments will be passed as arguments to the new client} \
-params .. \
-command-completion \
x11-new %{ %sh{
if [ -z "${kak_opt_termcmd}" ]; then
echo "echo -color Error 'termcmd option is not set'"
exit
fi
if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi
setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
}}
def -docstring %{x11-focus [<client>]: focus a given client's window
If no client is passed, then the current client is used} \
-params ..1 -client-completion \
x11-focus %{ %sh{
if [ $# -eq 1 ]; then
printf %s\\n "eval -client '$1' focus"
else
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
fi
} }
alias global focus x11-focus
alias global new x11-new