JamesRicky
JamesRicky

Reputation: 251

How to split Windows Terminal into 8 equal panes "programmatically"?

I am trying to split the new Windows Terminal into 8 equal panes by running one or more commands.

Recently Microsoft added support for splitting the new Windows Terminal into panes "programmatically" by using the parameters:

split-pane -H or -V (Horizontal or Vertical pane)

I have tried a dozen combinations of the parameters, but it splits the terminal windows "wrong".

Here is an example:

wt `; split-pane -V -p "pwsh" `; split-pane -H -p "pwsh" `; split-pane -V -p "pwsh"

Here is the desired result: Screenshot of 8 equally split panes in Windows Terminal How would I achieve this programmatically? It's possible to do in the Windows Terminal by using hotkeys ALT+SHIFT+MINUS and ALT+SHIFT+PLUS (see screenshot).

Upvotes: 4

Views: 1880

Answers (3)

Reinis
Reinis

Reputation: 136

this feature was recently added: https://github.com/microsoft/terminal/pull/8543

and included in version v1.6.10272.0 https://github.com/microsoft/terminal/releases/tag/v1.6.10272.0

splitPane and wt split-pane have grown support for "size" (float 0.0 - 1.0) and --size respectively

so you can specify what width you want the pane you are about to open to take of the currently selected pane using the --size argument and adding a decimal number (i.e. 0.5 for 50%).

so opening a Windows terminal with three panes of equal width running powershell would be done as so:

wt --maximized Powershell.exe -NoExit "Write-Host first" `
`; split-pane --vertical --size .66 Powershell.exe -NoExit "Write-Host second" `
`; split-pane --vertical --size .5 Powershell.exe -NoExit "Write-Host third"

Upvotes: 0

Joey
Joey

Reputation: 63

A little late but here is a solution

"startupActions": "-p \"Bash\" ; split-pane -p \"Bash\" -V ; move-focus left ;  split-pane -p \"Bash\" -H ; move-focus right;split-pane -p \"Bash\" -H ; move-focus up ; move-focus left ; split-pane -p \"Bash\" -V ; move-focus down ; split-pane -p \"Bash\" -V ; move-focus right ; move-focus up ; split-pane -p \"Bash\" -V move-focus down ; split-pane -p \"Bash\" -V"

It is not the prettiest but it is working.

Upvotes: 3

apena
apena

Reputation: 2321

Currenty this is simply not possible using wt.exe on its own however if you are using WSL you could do it with tmux.

In order to get equal spacing of the panes with wt.exe on its own, split-pane size control would need to be supported and that feature is currently in the backlog. Also I think you would probably need to 'nest' the split-pane commands and that is not yet possible in Window Terminal either.

Upvotes: 1

Related Questions