Vitor Durante
Vitor Durante

Reputation: 1063

How to open Windows Terminal with 4 panes?

I want to open 4 equal panes in Windows Terminal using wt.exe from command line. This is the intended result:

enter image description here

I have attempted using split-pane, but without a focus-pane command, it doesn't work.

Is it possible to do so in any other way?

Upvotes: 20

Views: 10763

Answers (5)

Open the settings of windows terminal (you can also use ctrl + ,).

At the "Actions" Tab, you can set (if it didn't) the keymap for resizing pane, in my setting it is set alt + shift + [direction], change the [direction] with right, left, up, or down arrow.

I also often to use Toggle Command Palette by pressing ctrl + shift + p then search for the keyword such as resize if I forgot the keymap. I can't post the image because of reputation restriction. I hope it could help.

Upvotes: 0

Vitor Durante
Vitor Durante

Reputation: 1063

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("%+-");

Upvotes: 10

halilintar8
halilintar8

Reputation: 801

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://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=net-5.0 https://learn.microsoft.com/en-us/windows/terminal/customize-settings/actions#move-pane-focus https://pureinfotech.com/set-image-background-windows-terminal/

Good Luck.

Upvotes: 5

tkit
tkit

Reputation: 8612

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.

Upvotes: 22

Ash Lawson
Ash Lawson

Reputation: 19

I'd like this, but I don't think it is possible currently.

The best I can manage is 3 panes, 1x Half and 2x Quarters. As you say, another split will always give 1x Half, 1x Quarter, 2x Eighths.

I tried with profiles to load another wt and split the first pane, but its always a new window/process.

Update: Its possible to moveFocus between panes with a keyboard shortcut, so it could be possible to write a PowerShell script that does this.

Upvotes: -1

Related Questions