2014-04-10 20:40:52 +02:00
|
|
|
# termcmd should be set such as the next argument is the whole
|
|
|
|
# command line to execute
|
2013-03-03 17:25:40 +01:00
|
|
|
decl str termcmd %sh{
|
2015-11-06 08:14:50 +01:00
|
|
|
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' \
|
2015-11-17 14:40:28 +01:00
|
|
|
'sakura -e ' \
|
2015-11-06 08:14:50 +01:00
|
|
|
'gnome-terminal -e ' \
|
|
|
|
'xfce4-terminal -e ' ; do
|
|
|
|
terminal=${termcmd%% *}
|
|
|
|
if which $terminal > /dev/null 2>&1; then
|
2016-01-10 21:41:46 +01:00
|
|
|
printf %s "'$termcmd'"
|
2015-11-06 08:14:50 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
2012-12-26 17:52:17 +01:00
|
|
|
}
|
|
|
|
|
2014-04-07 22:28:40 +02:00
|
|
|
def -docstring 'create a new kak client for current session' \
|
2015-12-01 15:00:55 +01:00
|
|
|
-params .. \
|
2015-06-26 14:52:01 +02:00
|
|
|
-command-completion \
|
2015-11-17 23:25:33 +01:00
|
|
|
x11-new %{ %sh{
|
2015-11-06 08:14:50 +01:00
|
|
|
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 &
|
2012-12-26 17:52:17 +01:00
|
|
|
}}
|
2014-04-07 22:28:40 +02:00
|
|
|
|
2016-01-24 14:18:14 +01:00
|
|
|
def -docstring 'create a new window for repl interaction' \
|
|
|
|
-params 0..1 \
|
|
|
|
-command-completion \
|
|
|
|
x11-repl %{ %sh{
|
|
|
|
if [ -z "${kak_opt_termcmd}" ]; then
|
|
|
|
echo "echo -color Error 'termcmd option is not set'"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ $# -eq 0 ]; then cmd="bash"; else cmd="$1"; fi
|
|
|
|
setsid ${kak_opt_termcmd} ${cmd} -t kak_repl_window < /dev/null > /dev/null 2>&1 &
|
|
|
|
}}
|
|
|
|
|
|
|
|
def x11-send-text -docstring "send selected text to the repl window" %{
|
|
|
|
%sh{
|
|
|
|
echo "${kak_selection}" | xsel -i
|
|
|
|
wid=$(xdotool getactivewindow)
|
|
|
|
xdotool search --name kak_repl_window windowactivate
|
|
|
|
xdotool key --clearmodifiers "Shift+Insert"
|
|
|
|
xdotool windowactivate $wid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-17 23:25:33 +01:00
|
|
|
def -docstring 'focus given client\'s window' \
|
2015-12-01 15:00:55 +01:00
|
|
|
-params 0..1 -client-completion \
|
2015-11-17 23:25:33 +01:00
|
|
|
x11-focus %{ %sh{
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
echo "echo -color Error 'too many arguments, use focus [client]'"
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
echo "eval -client '$1' focus"
|
|
|
|
else
|
|
|
|
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
|
|
|
fi
|
2014-04-07 22:28:40 +02:00
|
|
|
} }
|
2015-11-17 23:25:33 +01:00
|
|
|
|
|
|
|
alias global focus x11-focus
|
|
|
|
alias global new x11-new
|
2016-01-24 14:18:14 +01:00
|
|
|
alias global repl x11-repl
|
|
|
|
alias global send-text x11-send-text
|