How to open Windows Terminal with 4 panes?

I am able to do that with this single command from windows terminal (wt) :

wt -p "Command Prompt" `; sp -V -p "openSUSE-Leap-15-1" `; sp -H -p "Windows PowerShell"; [void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); Start-Sleep -s 2; [System.Windows.Forms.SendKeys]::SendWait("%{LEFT}"); Start-Sleep -s 2; [System.Windows.Forms.SendKeys]::SendWait("%+{5}")

it starts from top left and go as a clockwise, then stop at bottom left, in my windows terminal the sequences are : cmd prompt, opensuse, windows powershell, and kali linux,

it will opens 4 panes equally in windows terminal.

enter image description here

Run it on windows terminal (wt) with power shell.

Add these 2 examples in your windows terminal settings.json

{ "command": { "action": "splitPane", "split": "horizontal", "index": 4 }, "keys": "alt+shift+5" }

"backgroundImage": "%USERPROFILE%/Downloads/win_terminal_bg_img/kali_linux.jpg",
"backgroundImageOpacity": 0.3

where index 4 and alt shift 5 (("%+{5}")) refer to kali-linux in my windows terminal (wt) menu, and the image is for its background,

add those 2 examples sequentially and customize it with your wt menu.

Here are the tutorials :

https://www.howtogeek.com/673729/heres-why-the-new-windows-10-terminal-is-amazing/ https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=net-5.0 https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#move-pane-focus https://pureinfotech.com/set-image-background-windows-terminal/

Good Luck.


You can now start WT using wt.exe from the command line like this (I'm using Windows Terminal Preview version, I'm not sure if you need the Preview version for this or not):

wt split-pane -V; move-focus left; split-pane -H; move-focus right; split-pane -H

Alternatively, you can use the new startupActions setting for which you currently definitely need Windows Terminal Preview version.

I just answered myself in another thread about this. You can modify your Windows Terminal settings.json file by adding the following line to the root of your setting:

  "startupActions": "split-pane -V; move-focus left; split-pane -H; move-focus right; split-pane -H"

This means however that this will now be your default (even when you start WT from Start or from the taskbar, not only through the command line.


Update on 09/06/2021

We can finally achieve it through command line arguments. Here is a working example:

wt -M -d "./dir-a"; ^
split-pane -V -d "./dir-b"; ^
move-focus left; ^
split-pane -H -d "./dir-c"; ^
move-focus right; ^
split-pane -H -d "./dir-d"

Old Answer

I was able to get it working programatically using JScript. Not as beautiful as using wt.exe arguments, but it is the best we can do from a bat file nowadays.

@if (@X) == (@Y) @end /*
@cscript //E:JScript //nologo "%~f0" "%*"
@exit /b %errorlevel%
*/

// run windows terminal
var shell = WScript.CreateObject("WScript.Shell");
shell.run("wt.exe");
WScript.Sleep(500);

// ALT+SHIFT+=
shell.SendKeys("%+=");
WScript.Sleep(500);

// ALT+SHIFT+-
shell.SendKeys("%+-");
WScript.Sleep(500);

// focus left pane
shell.SendKeys("%{LEFT}");

// ALT+SHIFT+-
WScript.Sleep(500);
shell.SendKeys("%+-");