wezterm.kak (2774B)
1 # https://wezfurlong.org/wezterm/index.html 2 # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ 3 4 5 provide-module wezterm %{ 6 7 # ensure that we're running under WezTerm 8 evaluate-commands %sh{ 9 [ -z "${kak_opt_windowing_modules}" ] || [ -n "$WEZTERM_UNIX_SOCKET" ] || echo 'fail wezterm not detected' 10 } 11 12 define-command wezterm-terminal-impl -hidden -params 2.. %{ 13 nop %sh{ 14 wezterm cli "$@" 15 } 16 } 17 18 define-command wezterm-terminal-vertical -params 1.. -docstring ' 19 wezterm-terminal-vertical <program> [<arguments>]: create a new terminal as a wezterm pane 20 The current pane is split into two, top and bottom 21 The program passed as argument will be executed in the new terminal' \ 22 %{ 23 wezterm-terminal-impl split-pane --cwd "%val{client_env_PWD}" --bottom --pane-id "%val{client_env_WEZTERM_PANE}" -- %arg{@} 24 } 25 complete-command wezterm-terminal-vertical shell 26 27 define-command wezterm-terminal-horizontal -params 1.. -docstring ' 28 wezterm-terminal-horizontal <program> [<arguments>]: create a new terminal as a wezterm pane 29 The current pane is split into two, left and right 30 The program passed as argument will be executed in the new terminal' \ 31 %{ 32 wezterm-terminal-impl split-pane --cwd "%val{client_env_PWD}" --right --pane-id "%val{client_env_WEZTERM_PANE}" -- %arg{@} 33 } 34 complete-command wezterm-terminal-horizontal shell 35 36 define-command wezterm-terminal-tab -params 1.. -docstring ' 37 wezterm-terminal-tab <program> [<arguments>]: create a new terminal as a wezterm tab 38 The program passed as argument will be executed in the new terminal' \ 39 %{ 40 wezterm-terminal-impl spawn --cwd "%val{client_env_PWD}" --pane-id "%val{client_env_WEZTERM_PANE}" -- %arg{@} 41 } 42 complete-command wezterm-terminal-tab shell 43 44 define-command wezterm-terminal-window -params 1.. -docstring ' 45 wezterm-terminal-window <program> [<arguments>]: create a new terminal as a wezterm window 46 The program passed as argument will be executed in the new terminal' \ 47 %{ 48 wezterm-terminal-impl spawn --cwd "%val{client_env_PWD}" --new-window --pane-id "%val{client_env_WEZTERM_PANE}" -- %arg{@} 49 } 50 complete-command wezterm-terminal-window shell 51 52 define-command wezterm-focus -params ..1 -docstring ' 53 wezterm-focus [<client>]: focus the given client 54 If no client is passed then the current one is used' \ 55 %{ 56 evaluate-commands %sh{ 57 if [ $# -eq 1 ]; then 58 printf %s\\n " 59 evaluate-commands -client '$1' focus 60 " 61 elif [ -n "${kak_client_env_WEZTERM_PANE}" ]; then 62 wezterm cli activate-pane --pane-id "${kak_client_env_WEZTERM_PANE}" > /dev/null 2>&1 63 fi 64 } 65 } 66 complete-command -menu wezterm-focus client 67 68 alias global focus wezterm-focus 69 70 }