MicrosoftDocs / Console-Docs

Windows Console Docs Repo
Creative Commons Attribution 4.0 International
221 stars 84 forks source link

Need Help with Creating Tiled Arrangement for Microservices Panes in Windows Terminal #301

Closed brupelo closed 11 months ago

brupelo commented 1 year ago

Hi everyone,

I am facing an issue while working with multiple microservices in Windows Terminal. I have a command that spawns several microservices, but the problem arises because the service names are too long, making it difficult to read the entire title.

wt -w %~n0 ^
nt --title="shared" --startingDirectory=%ALIAS_DIR% %COMMAND_SHARED% ; ^
nt --title="svc-foo-bar-baz-boo-hoo0:5000" --startingDirectory=%svc-foo-bar-baz-boo-hoo0% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo1:5001" --startingDirectory=%svc-foo-bar-baz-boo-hoo1% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo2:5002" --startingDirectory=%svc-foo-bar-baz-boo-hoo2% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo3:5003" --startingDirectory=%svc-foo-bar-baz-boo-hoo3% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo4:5004" --startingDirectory=%svc-foo-bar-baz-boo-hoo4% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo5:5005" --startingDirectory=%svc-foo-bar-baz-boo-hoo5% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo6:5006" --startingDirectory=%svc-foo-bar-baz-boo-hoo6% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo7:5007" --startingDirectory=%svc-foo-bar-baz-boo-hoo7% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo8:5008" --startingDirectory=%svc-foo-bar-baz-boo-hoo8% %COMMAND% ; ^
nt --title="svc-foo-bar-baz-boo-hoo9:5009" --startingDirectory=%svc-foo-bar-baz-boo-hoo9% %COMMAND% 

I am looking for a way to create a tiled arrangement programmatically so that I can view all the titles at once. Just to give you an idea, I have the terminal maximized on a second monitor with a resolution of 1920x1080.

I have attempted to use panes and the split-pane command following the concept outlined in Microsoft's documentation, but I haven't been successful in achieving the desired layout. I suspect I might not fully understand the syntax, which is likely why I haven't managed to accomplish this task yet.

Could someone please provide an example of how to create a 4x2 or 2x4 tiled session where all the panes are of the same size? Alternatively, is it possible to programmatically create a layout similar to the one shown in this image, where panes 1 to 8 are the same size and pane 0 has the same width but twice the height?

I appreciate your assistance in advance!

Thank you!

zadjii-msft commented 1 year ago

without going into it too deep, try using:

Command Parameter Description Values
split-panesp --size,-s size Creates a new split window pane with the assigned size. Float that specifies the portion of the parent pane to use represented by a decimal. For example, .4 to represent 40% of the parent pane.

from https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows#split-pane-command

brupelo commented 1 year ago

@zadjii-msft Hey Mike, thanks for the fast reply. I appreciate it.

I'll definitely give it another shot. However, before posting my question, I had already attempted that particular command in my scripts without success. Can you clarify something for me quickly? In your opinion, is what I'm asking in this thread achievable with the current functionality of the latest wt version, especially the arrangement I've posted above?

In other words, is the current functionality flexible enough for users to create any type of arrangement, or are we constrained to just a few specific cases? I hope that makes sense. Your insights would be invaluable. Version I'm using:

Terminal (Portable) Version: 1.18.230526002-preview

Thank you!

brupelo commented 1 year ago

@zadjii-msft I have a question regarding the underlying behavior of pane splitting. Correct me if I'm wrong, but I understand that there's an underlying tree structure when splitting panes, am I right? My specific query is: Is it possible to specify the current parent pane from which new child panes are created?

I'm curious about this functionality and would appreciate any insights you could provide on this matter. Thank you!

zadjii-msft commented 1 year ago

Sorry, I've been preoccupied with some other tasks and deeply behind on mail.

I'm 100% confident that the kind of arrangement you're talking about is possible, you just need to be pre-emptive about things. You need to make sure to think about it procedurally. For example:

wt -w -1 nt ; sp -V -s .75 ; sp -H -s .50 ; mf up ; sp -V -s .75

image

which you can read like: "Split the first pane to a 25%|75% split, then split that in half, go to the top, split that 25%|75%..."

Build on that, and get:

wt -w -1 nt ; sp -V -s .75 ; sp -H -s .50 ; mf up ; sp -V -s .75 ; sp -V -s .66 ; sp -V -s .50 ; mf down ; sp -V -s .75

which will get you image

so on and so forth

brupelo commented 11 months ago

@zadjii-msft Cool stuff! Your explanation, along with the examples provided, has been incredibly helpful. I found your answer to be notably clearer and more comprehensible compared to the official documentation regarding this subject.

Discovering the mf command through your guidance was an eye-opener for me. Once again, thank you for taking the time to share your expertise. Your contribution has made a significant difference in my understanding of this extremely useful feature :)

brupelo commented 11 months ago

Solved in https://github.com/MicrosoftDocs/Console-Docs/issues/301#issuecomment-1802238845