add client.kak providing 'new' command for opening a new client

Autodetect tmux, use tmux if we are in a tmux session, else fallback to
urxvt.
This commit is contained in:
Maxime Coste 2012-12-26 17:52:17 +01:00
parent feef062344
commit 5939eb219f
3 changed files with 20 additions and 1 deletions

View File

@ -454,3 +454,9 @@ Existing commands files are:
* *rc/ctags.kak*: provides the +tag+ command to jump on a tag definition using
exuberant ctags files, this script requires the *readtags* binary, available
in the exuberant ctags package but not installed by default.
* *rc/client.kak*: provides the +new+ command to launch a new client on the current
session, if tmux is detected, launch the client in a new tmux split, else
launch in a new terminal emulator.
Certain command files defines options, such as grepcmd (for :grep) or
termcmd (for :new).

View File

@ -23,6 +23,6 @@ XDG_CONFIG_HOME ?= $(HOME)/.config
userconfig:
mkdir -p $(XDG_CONFIG_HOME)/kak/autoload
ln -rs rc/{asciidoc,cpp,diff,git,grep,kakrc,make}.kak $(XDG_CONFIG_HOME)/kak/autoload/
ln -rs rc/{asciidoc,client,cpp,diff,git,grep,kakrc,make}.kak $(XDG_CONFIG_HOME)/kak/autoload/
.PHONY: tags userconfig

13
src/rc/client.kak Normal file
View File

@ -0,0 +1,13 @@
setg termcmd %sh{
if [[ -n "$TMUX" ]]; then
echo "'tmux split-window -h'"
else
echo "'urxvt -e sh -c'"
fi
}
def new -shell-params %{ nop %sh{
if (( $# != 0 )); then kakoune_params="-e '$@'"; fi
${kak_opt_termcmd} "kak -c ${kak_socket#/tmp/kak-} ${kakoune_params}" < /dev/null >& /dev/null &
disown
}}