2018-04-19 19:28:32 +02:00
|
|
|
# termcmd should be set such as the next argument is the whole
|
2014-04-10 20:40:52 +02:00
|
|
|
# command line to execute
|
2017-11-03 08:34:41 +01:00
|
|
|
declare-option -docstring %{shell command run to spawn a new terminal
|
2018-04-19 19:28:32 +02:00
|
|
|
A shell command is appended to the one set in this option at runtime} \
|
2017-05-16 13:35:43 +02:00
|
|
|
str termcmd %sh{
|
2017-06-08 19:02:44 +02:00
|
|
|
for termcmd in 'alacritty -e sh -c' \
|
2018-06-19 09:38:15 +02:00
|
|
|
'kitty sh -c' \
|
2017-06-08 19:02:44 +02:00
|
|
|
'termite -e ' \
|
2015-11-06 08:14:50 +01:00
|
|
|
'urxvt -e sh -c' \
|
|
|
|
'rxvt -e sh -c' \
|
|
|
|
'xterm -e sh -c' \
|
|
|
|
'roxterm -e sh -c' \
|
|
|
|
'mintty -e sh -c' \
|
2017-07-25 10:26:52 +02:00
|
|
|
'sakura -x ' \
|
2015-11-06 08:14:50 +01:00
|
|
|
'gnome-terminal -e ' \
|
|
|
|
'xfce4-terminal -e ' ; do
|
|
|
|
terminal=${termcmd%% *}
|
2017-05-16 14:18:45 +02:00
|
|
|
if command -v $terminal >/dev/null 2>&1; then
|
2018-05-06 23:29:52 +02:00
|
|
|
printf %s\\n "$termcmd"
|
2015-11-06 08:14:50 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
2012-12-26 17:52:17 +01:00
|
|
|
}
|
|
|
|
|
2018-12-02 13:59:45 +01:00
|
|
|
define-command x11-terminal -params 1.. -shell-completion -docstring '
|
|
|
|
x11-terminal <program> [<arguments>]: create a new terminal as an x11 window
|
|
|
|
The program passed as argument will be executed in the new terminal' \
|
|
|
|
%{
|
|
|
|
evaluate-commands %sh{
|
2015-11-06 08:14:50 +01:00
|
|
|
if [ -z "${kak_opt_termcmd}" ]; then
|
2018-12-02 13:59:45 +01:00
|
|
|
echo "fail 'termcmd option is not set'"
|
2015-11-06 08:14:50 +01:00
|
|
|
exit
|
|
|
|
fi
|
2018-12-02 13:59:45 +01:00
|
|
|
setsid ${kak_opt_termcmd} "$*" < /dev/null > /dev/null 2>&1 &
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define-command x11-new -params .. -command-completion -docstring '
|
|
|
|
x11-new [<commands>]: create a new kakoune client as an x11 window
|
|
|
|
The optional arguments are passed as commands to the new client' \
|
|
|
|
%{
|
|
|
|
x11-terminal "kak -c %val{session} -e '%arg{@}'"
|
|
|
|
}
|
2014-04-07 22:28:40 +02:00
|
|
|
|
2018-12-02 13:59:45 +01:00
|
|
|
define-command x11-focus -params ..1 -client-completion -docstring '
|
|
|
|
x11-focus [<kakoune_client>]: focus a given client''s window
|
|
|
|
If no client is passed, then the current client is used' \
|
|
|
|
%{
|
|
|
|
evaluate-commands %sh{
|
2016-10-11 09:03:41 +02:00
|
|
|
if [ $# -eq 1 ]; then
|
2018-12-02 13:59:45 +01:00
|
|
|
printf "evaluate-commands -client '%s' focus" "$1"
|
2015-11-17 23:25:33 +01:00
|
|
|
else
|
|
|
|
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
|
|
|
fi
|
2018-12-02 13:59:45 +01:00
|
|
|
}
|
|
|
|
}
|
2015-11-17 23:25:33 +01:00
|
|
|
|
|
|
|
alias global focus x11-focus
|
|
|
|
alias global new x11-new
|
2018-12-02 13:59:45 +01:00
|
|
|
alias global terminal x11-terminal
|