diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-04-10 19:40:52 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-04-10 19:41:43 +0100 |
| commit | cd6d7fdd3cfc39da3e4e54bbee9524c3a6bf39d0 (patch) | |
| tree | c24a4118a3ef564f596c521b5ab5b6c849bd9f4e | |
| parent | 19868f01c8431b4ff253e264d32725df4cd75622 (diff) | |
client.kak: improve termcmd autodetection
| -rw-r--r-- | rc/client.kak | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/rc/client.kak b/rc/client.kak index cd0dfe5d..e9591b7a 100644 --- a/rc/client.kak +++ b/rc/client.kak @@ -1,16 +1,33 @@ +# termcmd should be set such as the next argument is the whole +# command line to execute decl str termcmd %sh{ if [ -n "$TMUX" ]; then echo "'tmux split-window -h'" else - echo "'urxvt -e sh -c'" + for terminal in urxvt rxvt xterm roxterm mintty; do + if which $terminal > /dev/null 2>&1; then + echo "'$terminal -e sh -c'" + exit + fi + done + for terminal in gnome-terminal xfce4-terminal; do + if which $terminal > /dev/null 2>&1; then + echo "'$terminal -e'" + exit + fi + done fi } def -docstring 'create a new kak client for current session' \ -shell-params \ - new %{ nop %sh{ - if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi - setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 & + 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 'focus given client' \ |
