Skip to content

Instantly share code, notes, and snippets.

@jcmkk3
Last active June 18, 2025 03:24
Show Gist options
  • Save jcmkk3/57d73cf34a47c7b7da77699b50b3ecad to your computer and use it in GitHub Desktop.
Save jcmkk3/57d73cf34a47c7b7da77699b50b3ecad to your computer and use it in GitHub Desktop.
windowsterminal.kak

To use, copy file to ~/.config/kak/ directory and add the following lines to your kakrc:

set -add global windowing_modules windowsterminal
require-module windowsterminal
# https://learn.microsoft.com/en-us/windows/terminal/
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
provide-module windowsterminal %{
# ensure that we're running under Windows Terminal
evaluate-commands %sh{
[ -z "${kak_opt_windowing_modules}" ] || [ -n "$WT_SESSION" ] || echo 'fail wt.exe not detected'
}
define-command windowsterminal-terminal-impl -hidden -params 2.. %{
nop %sh{
wt.exe --window 0 "$@"
}
}
define-command windowsterminal-terminal-vertical -params 1.. -docstring '
windowsterminal-terminal-vertical <program> [<arguments>]: create a new terminal as a Windows Terminal pane
The current pane is split into two, top and bottom
The program passed as argument will be executed in the new terminal' \
%{
windowsterminal-terminal-impl split-pane --vertical --startingDirectory "%val{client_env_PWD}" --profile "%val{client_env_WT_PROFILE_ID}" wsl.exe -- %arg{@}
}
complete-command windowsterminal-terminal-vertical shell
define-command windowsterminal-terminal-horizontal -params 1.. -docstring '
windowsterminal-terminal-horizontal <program> [<arguments>]: create a new terminal as a Windows Terminal pane
The current pane is split into two, left and right
The program passed as argument will be executed in the new terminal' \
%{
windowsterminal-terminal-impl split-pane --horizontal --startingDirectory "%val{client_env_PWD}" --profile "%val{client_env_WT_PROFILE_ID}" wsl.exe -- %arg{@}
}
complete-command windowsterminal-terminal-horizontal shell
define-command windowsterminal-terminal-tab -params 1.. -docstring '
windowsterminal-terminal-tab <program> [<arguments>]: create a new terminal as a Windows Terminal tab
The program passed as argument will be executed in the new terminal' \
%{
windowsterminal-terminal-impl new-tab --startingDirectory "%val{client_env_PWD}" --profile "%val{client_env_WT_PROFILE_ID}" wsl.exe -- %arg{@}
}
complete-command windowsterminal-terminal-tab shell
define-command windowsterminal-terminal-window -params 1.. -docstring '
windowsterminal-terminal-window <program> [<arguments>]: create a new terminal as a Windows Terminal window
The program passed as argument will be executed in the new terminal' \
%{
windowsterminal-terminal-impl --startingDirectory "%val{client_env_PWD}" --profile "%val{client_env_WT_PROFILE_ID}" wsl.exe -- %arg{@}
}
complete-command windowsterminal-terminal-window shell
define-command windowsterminal-focus -params ..1 -docstring '
windowsterminal-focus [<client>]: focus the given client
If no client is passed then the current one is used' \
%{
fail 'Focusing wt.exe client is unimplemented'
}
complete-command -menu windowsterminal-focus client
alias global focus windowsterminal-focus
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment