746e0d032f
Today I can control "terminal" and "new" by changing the terminal alias but I always need to choose a concrete implementation, like "tmux-terminal-horizontal", even when there is otherwise no need to mention tmux in my config. Allow to configure windowing system and window placement independently by introducing dedicated options. This allows to create mappings that work in any windowing system like map global user c %{:with-option windowing_placement window new<ret>} map global user '"' %{:with-option windowing_placement vertical new<ret>} map global user '%' %{:with-option windowing_placement horizontal new<ret>} For windowing systems that don't support all placements, you can wrap the above in try/catch to fall back on the "window" variant which is defined for all windowing systems. When using multiple (nested) windowing systems, you might want to add mappings like map global user t %{:with-option windowing_module tmux new<ret>} map global user T %{:with-option windowing_module wayland new<ret>} --- This changes the default "terminal" alias for some modules. In particular, instead of delegating to iterm-terminal-vertical screen-terminal-vertical tmux-terminal-horizontal wezterm-terminal-vertical it will now by default delegate to the respective "-window" variant. We could maintain backwards compatiblity here by setting the "windowing_placement" option accordingly, but the new behavior seems more logical? Also, this removes the "terminal-tab" alias which was only defined by the kitty module. We could try to keep the alias approach and implement a "with-alias" command, however that approach can only capture both dimensions (windowing system and placement) if we add tons of commands like "terminal-horizontal" (with implied windowing system) and "tmux-terminal" (with implied placement). Side thought: we could also get rid of the "focus" alias and instead define define-command focus %{ "%opt{windowing_module}-focus" } Closes #3943, #4425
71 lines
2.5 KiB
Plaintext
71 lines
2.5 KiB
Plaintext
# 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 <program> [<arguments>]: 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 --cwd "%val{client_env_PWD}" --bottom -- %arg{@}
|
|
}
|
|
complete-command wezterm-terminal-vertical shell
|
|
|
|
define-command wezterm-terminal-horizontal -params 1.. -docstring '
|
|
wezterm-terminal-horizontal <program> [<arguments>]: 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 --cwd "%val{client_env_PWD}" --right -- %arg{@}
|
|
}
|
|
complete-command wezterm-terminal-horizontal shell
|
|
|
|
define-command wezterm-terminal-tab -params 1.. -docstring '
|
|
wezterm-terminal-tab <program> [<arguments>]: create a new terminal as a wezterm tab
|
|
The program passed as argument will be executed in the new terminal' \
|
|
%{
|
|
wezterm-terminal-impl spawn --cwd "%val{client_env_PWD}" -- %arg{@}
|
|
}
|
|
complete-command wezterm-terminal-tab shell
|
|
|
|
define-command wezterm-terminal-window -params 1.. -docstring '
|
|
wezterm-terminal-window <program> [<arguments>]: create a new terminal as a wezterm window
|
|
The program passed as argument will be executed in the new terminal' \
|
|
%{
|
|
wezterm-terminal-impl spawn --cwd "%val{client_env_PWD}" --new-window -- %arg{@}
|
|
}
|
|
complete-command wezterm-terminal-window shell
|
|
|
|
define-command wezterm-focus -params ..1 -docstring '
|
|
wezterm-focus [<client>]: 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
|
|
|
|
}
|