diff --git a/rc/base/new-client.kak b/rc/base/new-client.kak new file mode 100644 index 00000000..4413d6e2 --- /dev/null +++ b/rc/base/new-client.kak @@ -0,0 +1,16 @@ +define-command new -params .. -command-completion -docstring ' +new []: create a new kakoune client +The ''terminal'' alias is being used to determine the user''s preferred terminal emulator +The optional arguments are passed as commands to the new client' \ +%{ + try %{ + terminal %sh{ + # double-up single-quotes + escaped=$(printf %s "$*" | sed -e "s|'|''|g") + printf "kak -c '%s' -e '%s'" "$kak_session" "$escaped" + } + } catch %{ + fail "The 'terminal' alias must be defined to use this command" + } +} + diff --git a/rc/base/screen.kak b/rc/base/screen.kak index 5bf4292c..dca8c5be 100644 --- a/rc/base/screen.kak +++ b/rc/base/screen.kak @@ -5,7 +5,6 @@ hook -group GNUscreen global KakBegin .* %sh{ [ -z "${STY}" ] && exit echo " alias global focus screen-focus - alias global new screen-new-vertical alias global terminal screen-terminal-vertical " } @@ -42,27 +41,6 @@ The shell program passed as argument will be executed in the new terminal' \ } } -define-command screen-new-vertical -params .. -command-completion -docstring ' -screen-new-vertical []: create a new kakoune client as a screen pane -The current pane is split into two, left and right -The optional arguments are passed as commands to the new client' \ -%{ - screen-terminal-vertical "kak -c '%val{session}' -e '%arg{@}'" -} -define-command screen-new-horizontal -params .. -command-completion -docstring ' -screen-new-horizontal []: create a new kakoune client as a screen pane -The current pane is split into two, top and bottom -The optional arguments are passed as commands to the new client' \ -%{ - screen-terminal-horizontal "kak -c '%val{session}' -e '%arg{@}'" -} -define-command screen-new-window -params .. -command-completion -docstring ' -screen-new-window []: create a new kakoune client as a screen window -The optional arguments are passed as commands to the new client' \ -%{ - screen-terminal-window "kak -c '%val{session}' -e '%arg{@}'" -} - define-command screen-focus -params ..1 -client-completion -docstring ' screen-focus []: focus the given client If no client is passed then the current one is used' \ diff --git a/rc/base/tmux.kak b/rc/base/tmux.kak index b1d6beb5..23a381e2 100644 --- a/rc/base/tmux.kak +++ b/rc/base/tmux.kak @@ -6,7 +6,6 @@ hook global KakBegin .* %sh{ if [ -n "$TMUX" ]; then echo " alias global focus tmux-focus - alias global new tmux-new-horizontal alias global terminal tmux-terminal-horizontal " fi @@ -45,27 +44,6 @@ The shell program passed as argument will be executed in the new terminal' \ tmux-terminal-impl 'new-window' %arg{1} } -define-command tmux-new-vertical -params .. -command-completion -docstring ' -tmux-new-vertical []: create a new kakoune client as a tmux pane -The current pane is split into two, top and bottom -The optional arguments are passed as commands to the new client' \ -%{ - tmux-terminal-vertical "kak -c '%val{session}' -e '%arg{@}'" -} -define-command tmux-new-horizontal -params .. -command-completion -docstring ' -tmux-new-horizontal []: create a new kakoune client as a tmux pane -The current pane is split into two, left and right -The optional arguments are passed as commands to the new client' \ -%{ - tmux-terminal-horizontal "kak -c '%val{session}' -e '%arg{@}'" -} -define-command tmux-new-window -params .. -command-completion -docstring ' -tmux-new-window []: create a new kakoune client as a tmux window -The optional arguments are passed as commands to the new client' \ -%{ - tmux-terminal-window "kak -c '%val{session}' -e '%arg{@}'" -} - define-command tmux-focus -params ..1 -client-completion -docstring ' tmux-focus []: focus the given client If no client is passed then the current one is used' \ diff --git a/rc/base/x11.kak b/rc/base/x11.kak index c6f298d8..fea97bbd 100644 --- a/rc/base/x11.kak +++ b/rc/base/x11.kak @@ -35,13 +35,6 @@ The shell program passed as argument will be executed in the new terminal' \ } } -define-command x11-new -params .. -command-completion -docstring ' -x11-new []: 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{@}'" -} - define-command x11-focus -params ..1 -client-completion -docstring ' x11-focus []: focus a given client''s window If no client is passed, then the current client is used' \ @@ -56,5 +49,4 @@ If no client is passed, then the current client is used' \ } alias global focus x11-focus -alias global new x11-new alias global terminal x11-terminal diff --git a/rc/extra/iterm.kak b/rc/extra/iterm.kak index 135de775..65fdc3dc 100644 --- a/rc/extra/iterm.kak +++ b/rc/extra/iterm.kak @@ -6,7 +6,6 @@ hook global KakBegin .* %sh{ if [ "$TERM_PROGRAM" = "iTerm.app" ] && [ -z "$TMUX" ]; then echo " - alias global new iterm-new-vertical alias global focus iterm-focus " fi @@ -72,33 +71,6 @@ The shell program passed as argument will be executed in the new terminal'\ } } -define-command iterm-new-vertical -params .. -command-completion -docstring ' -iterm-new-vertical : create a new kakoune client as an iterm pane -The current pane is split into two, top and bottom -The optional arguments are passed as commands to the new client' \ -%{ - iterm-terminal-vertical "kak -c '%val{session}' -e '%arg{@}'" -} -define-command iterm-new-horizontal -params .. -command-completion -docstring ' -iterm-new-horizontal : create a new kakoune client as an iterm pane -The current pane is split into two, left and right -The optional arguments are passed as commands to the new client' \ -%{ - iterm-terminal-horizontal "kak -c '%val{session}' -e '%arg{@}'" -} -define-command iterm-new-tab -params .. -command-completion -docstring ' -iterm-new-tab : create a new kakoune client as an iterm tab -The optional arguments are passed as commands to the new client' \ -%{ - iterm-terminal-tab "kak -c '%val{session}' -e '%arg{@}'" -} -define-command iterm-new-window -params .. -command-completion -docstring ' -iterm-new-window : create a new kakoune client as an iterm window -The optional arguments are passed as commands to the new client' \ -%{ - iterm-terminal-window "kak -c '%val{session}' -e '%arg{@}'" -} - define-command iterm-focus -params ..1 -client-completion -docstring ' iterm-focus []: focus the given client If no client is passed then the current one is used' \ diff --git a/rc/extra/kitty.kak b/rc/extra/kitty.kak index 5f0bb24c..56931423 100644 --- a/rc/extra/kitty.kak +++ b/rc/extra/kitty.kak @@ -3,8 +3,6 @@ declare-option -docstring %{window type that kitty creates on new and repl calls hook -group kitty-hooks global KakBegin .* %sh{ if [ "$TERM" = "xterm-kitty" ] && [ -z "$TMUX" ]; then echo " - alias global new kitty-new - alias global new-tab kitty-new-tab alias global terminal kitty-terminal alias global terminal-tab kitty-terminal-tab alias global focus kitty-focus @@ -23,13 +21,6 @@ The shell program passed as argument will be executed in the new terminal' \ } } -define-command kitty-new -params .. -command-completion -docstring ' -kitty-new []: create a new kakoune client as a kitty window -The optional arguments are passed as commands to the new client' \ -%{ - kitty-terminal "kak -c %val{session} -e '%arg{@}'" -} - define-command kitty-terminal-tab -params 1 -shell-completion -docstring ' kitty-terminal-tab : create a new terminal as kitty tab The shell program passed as argument will be executed in the new terminal' \ @@ -39,13 +30,6 @@ The shell program passed as argument will be executed in the new terminal' \ } } -define-command kitty-new-tab -params .. -command-completion -docstring ' -kitty-new-tab []: create a new terminal as kitty tab -The optional arguments are passed as commands to the new client' \ -%{ - kitty-terminal-tab "kak -c %val{session} -e '%arg{@}'" -} - define-command kitty-focus -params ..1 -client-completion -docstring ' kitty-focus []: focus the given client If no client is passed then the current one is used' \