diff --git a/README.asciidoc b/README.asciidoc index 8eaf45e6..d42bfb8c 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -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). diff --git a/src/Makefile b/src/Makefile index 753847fc..7424f2fa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 diff --git a/src/rc/client.kak b/src/rc/client.kak new file mode 100644 index 00000000..6bb0cd05 --- /dev/null +++ b/src/rc/client.kak @@ -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 +}}