MicrosoftDocs / terminal

Creative Commons Attribution 4.0 International
468 stars 171 forks source link

Create a guide for starting with multiple tabs/panes using Command Palette and/or `startupActions` #315

Open zadjii-msft opened 3 years ago

zadjii-msft commented 3 years ago

We get dupes of microsoft/terminal#766 literally all the time in the main repo. Maybe it would be useful to add a guide on using the command palette / startupActions to alleviate that pain. Below is the text I use as a saved reply for these dupes. Someone just needs to massage this into a guide on the Tips and Tricks page.


Thanks for the suggestion! Looks like we're tracking this in microsoft/terminal#776.

dup #766


So for reference, I like to do like the following each time I boot up the Terminal in the morning:

{ "command": { "action": "wt", "commandline": "new-tab --title OpenConsole cmd.exe /k #work 15 ; split-pane -s .30 --title OpenConsole cmd.exe /k #work 15 ; split-pane  -s .25 -H cmd.exe /k media ; new-tab --title \"Symbols Script\" powershell dev\\symbols.ps1 ; new-tab -p \"Ubuntu 18.04\" ; new-tab -p \"microsoft/Terminal\" ; sp -V -p \"microsoft/Terminal\" ; sp -H -p \"microsoft/Terminal\" ; focus-tab -t 0" }, "name": "Good Morning" },

(you could probably make it shorter by replacing new-tab/split-pane with nt/sp, respectively).

I add that to the keybindings/actions. This creates a new command in the Command Palette named "Good Morning". That opens up a few tabs & panes, running various build environments. I like having it in a command rather than startupActions, because I only really want this in one terminal window, not every single one I launch. It's personal taste.

You could repeat this for multiple different "session"s if you wanted. That way you could have layouts pre-defined for various different dev environments.

We're also tracking adding commands to the new tab dropdown in microsoft/terminal#1571.

zorgick commented 3 years ago

Hi @zadjii-msft I just found your trick and I'm trying to implement it according to my needs, but I'm struggling to do it correctly.

When I run this command,

{ "command": { "action": "wt", "commandline": "nt wsl.exe ; sp -H -s .30 wsl.exe ; sp -V wsl.exe ; sp -V wsl.exe ; focus-tab -t 0" }, "name": "Good Morning" },

I want my session to look like this, image

But instead bottom panes are not split equally, and I receive this

image

Do you know how to make WT to resize panes equally using WT commands?

Or maybe there is a way to preserve a session like in tmux?

BrunoBlanes commented 3 years ago

@zorgick you can add -s .66 to you first split in the lower section to specify that you want 66% of the space left, which in turn would make the first pane 34% and the last two would split equally at 33%. That's the closest you'll get to a perfect 1/3 split.