I recently switched to a Windows PC for development and have for years been used to navigating between vim splits and terminal splits using the same key binding, I had this working very well using kitty on macOS. I am on a corporate machine now and I have to use Windows Terminal. Windows Terminal has splits, and I can control it using key bindings. However, I was wondering whether Windows Terminal has an API, so that I can implement Navigator.nvim for Windows Terminal, and get my old Vim/terminal split integration working again.
Is this possible in Windows Terminal?
While there's not an API, the wt.exe
command itself gives you a lot of control over existing Windows Terminal sessions. It seems to me that you would be able to set up Neovim keybindings to run any of the following commands. See Using command line arguments for Windows Terminal for a complete list of commands.
For instance, to create a new vertical split with the default profile:
wt.exe -w last split-pane
The --window/-w last
sends the command to the most recently used Windows Terminal instance.
Some other examples:
# New horizontal split
wt.exe -w last split-pane -H
# Move up a pane when you have a horizontal split
wt.exe -w last mf up
wt.exe -w last move-focus up
# Move right a pane when you have a vertical split
wt.exe -w last mf right
wt.exe -w last move-focus right
# Open a new tab with the default WSL distribution in the WSL user's home directory
wt.exe -w last new-tab wsl.exe '~'
If you are using WSL, you'll need to use the full wt.exe
. PowerShell and CMD can just use wt
(or the alternative versions listed in the doc linked above).