Search code examples
sshwindows-terminal

Automatically connect Windows Terminal to SSH in multiple equal-sized panels


A number of questions are related to using SSH with Windows terminal and a few others are related to opening multiple, equal sized panels side-by-side. None of these questions actually offers an answer to achieve the desired result (see title).

Some outdated answers say it's not possible, but after a recent update it now should be.

This answer explains how to open multiple equal-sized panes side-by-side. However, it does not explain how to execute a command within those newly opened panes.


Solution

  • Based on the answer by tkit on this question,, which explains how to open multiple panels side-by-side. We can include a SSH command as follows:

    wt -M ssh user@ip.address -p 10077; split-pane -V ssh user@ip.address; move-focus left; split-pane -H ssh user@ip.address; move-focus right; split-pane -H ssh user@ip.address
    

    This gives the following result:

    enter image description here

    Explanation of the command:

    wt opens a Windows Terminal. After this flags can be used such as -M to maximize the window. Following this follows the command, ssh commands in this case. Flags can follow the given command, here -p for port number on the ssh command. The ; splits commands given to wt. split-pane results in a -V vertical panel split. move-focus changes the currently focused. Without move-focus we would end up with panels at size 50%, 25%, 12.5% and 12.%