From b64dce3e95a7d28da60c48aa73815c5e22804e8a Mon Sep 17 00:00:00 2001 From: Bob Qi Date: Fri, 9 Jun 2023 15:43:07 +0800 Subject: [PATCH 1/2] rc/windowing/wezterm.kak --- rc/windowing/detection.kak | 2 +- rc/windowing/wezterm.kak | 71 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 rc/windowing/wezterm.kak diff --git a/rc/windowing/detection.kak b/rc/windowing/detection.kak index 6e4b71e0..6844c45b 100644 --- a/rc/windowing/detection.kak +++ b/rc/windowing/detection.kak @@ -23,7 +23,7 @@ declare-option -docstring \ "Ordered list of windowing modules to try and load. An empty list disables both automatic module loading and environment detection, enabling complete manual control of the module loading." \ -str-list windowing_modules 'tmux' 'screen' 'zellij' 'kitty' 'iterm' 'sway' 'wayland' 'x11' +str-list windowing_modules 'tmux' 'screen' 'zellij' 'kitty' 'iterm' 'sway' 'wayland' 'x11' 'wezterm' hook -group windowing global KakBegin .* %{ diff --git a/rc/windowing/wezterm.kak b/rc/windowing/wezterm.kak new file mode 100644 index 00000000..d21dde2b --- /dev/null +++ b/rc/windowing/wezterm.kak @@ -0,0 +1,71 @@ +# https://wezfurlong.org/wezterm/index.html +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + + +provide-module wezterm %{ + +# ensure that we're running under screen +evaluate-commands %sh{ + [ -z "${kak_opt_windowing_modules}" ] || [ -n "$WEZTERM_UNIX_SOCKET" ] || echo 'fail wezterm not detected' +} + +define-command wezterm-terminal-impl -hidden -params 2.. %{ + nop %sh{ + wezterm cli $@ + } +} + +define-command wezterm-terminal-vertical -params 1.. -docstring ' +wezterm-terminal-vertical [] []: create a new terminal as a wezterm pane +The current pane is split into two, top and bottom +The program passed as argument will be executed in the new terminal' \ +%{ + wezterm-terminal-impl split-pane --bottom -- %arg{@} +} +complete-command wezterm-terminal-vertical shell + +define-command wezterm-terminal-horizontal -params 1.. -docstring ' +wezterm-terminal-horizontal []: create a new terminal as a wezterm pane +The current pane is split into two, left and right +The program passed as argument will be executed in the new terminal' \ +%{ + wezterm-terminal-impl split-pane --right -- %arg{@} +} +complete-command wezterm-terminal-horizontal shell + +define-command wezterm-terminal-tab -params 1.. -docstring ' +wezterm-terminal-tab []: create a new terminal as a wezterm tab +The program passed as argument will be executed in the new terminal' \ +%{ + wezterm-terminal-impl spawn -- %arg{@} +} +complete-command wezterm-terminal-tab shell + +define-command wezterm-terminal-window -params 1.. -docstring ' +wezterm-terminal-window []: create a new terminal as a wezterm window +The program passed as argument will be executed in the new terminal' \ +%{ + wezterm-terminal-impl spawn --new-window -- %arg{@} +} +complete-command wezterm-terminal-window shell + +define-command wezterm-focus -params ..1 -docstring ' +wezterm-focus []: focus the given client +If no client is passed then the current one is used' \ +%{ + evaluate-commands %sh{ + if [ $# -eq 1 ]; then + printf %s\\n " + evaluate-commands -client '$1' focus + " + elif [ -n "${kak_client_env_WEZTERM_PANE}" ]; then + wezterm cli activate-pane --pane-id "${kak_client_env_WEZTERM_PANE}" > /dev/null 2>&1 + fi + } +} +complete-command -menu wezterm-focus client + +alias global focus wezterm-focus +alias global terminal wezterm-terminal-vertical + +} From 365fe588263371bc51173c5594ef85c6e9742e79 Mon Sep 17 00:00:00 2001 From: Bob Qi Date: Fri, 9 Jun 2023 17:57:48 +0800 Subject: [PATCH 2/2] fix arg quoting --- rc/windowing/wezterm.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/windowing/wezterm.kak b/rc/windowing/wezterm.kak index d21dde2b..ddb473be 100644 --- a/rc/windowing/wezterm.kak +++ b/rc/windowing/wezterm.kak @@ -11,7 +11,7 @@ evaluate-commands %sh{ define-command wezterm-terminal-impl -hidden -params 2.. %{ nop %sh{ - wezterm cli $@ + wezterm cli "$@" } }