Controlling Windows Terminal with KEYSTACK

May 20, 2008
11,045
90
Syracuse, NY, USA
I have been playing with Windows Terminal. Earlier today I wanted an instance of WSL in a vertically-split pane, next to TCC. That would require opening Terminal's drop-down actions menu (Ctrl-Shift-Space) and pressing Alt-Enter on "Ubuntu".

1598121617399.png


To my surprise (especially the first key below), this works.

Code:
keystack Ctrl-Shift-" " Down 3 Alt-Enter
 
  • Like
Reactions: Joe Caverly
May 20, 2008
11,045
90
Syracuse, NY, USA
Here's a much better way. In settings.json's "keybindings" section ...

Code:
{ "command": { "action": "splitPane", "split": "auto", "profile": "Ubuntu"}, "keys": "alt+shift+u" }

Amazing! It worked the first time.
 
  • Like
Reactions: Joe Caverly
May 20, 2008
11,045
90
Syracuse, NY, USA
P.S. I didn't try it but, according to the docs, you can specify "commandLine" (instead of "profile"), to run something that doesn't have a profile.
 
Here's a much better way. In settings.json's "keybindings" section ...

Thanks for that @vefatica. Works great!
Code:
        {
            "command": {
                "action": "splitPane",
                "split": "auto",
                "profile": "Windows PowerShell"
            },
            "keys": "alt+shift+p"
        }
I have also added a program to the launch list;
Code:
            {
                "guid": "{6B92BB33-361E-4A41-9BFD-D4E5C89739D4}",
                "hidden": false,
                "name": "HBRun",
                "commandline": "E:\\hb34\\bin\\hbrun.exe",
                "hidden": false,
                "fontSize": 20,
                "startingDirectory": "E://Utils",
                "tabTitle": "HBRun"
            }
1598234580824.png

1598234654684.png

Joe
 
May 20, 2008
11,045
90
Syracuse, NY, USA
I tried getting "commandLine" (instead of "profile") to work. It wouldn't work. It kept giving me a split pane with the default profile (TCC) in it. I asked about it on GitHub ... just this moment got a reply. The reply said the JSON file is case-sensitive and to use "commandline".

"commandline" does work but Windows Terminal Key Bindings says "commandLine". I commented on that too.

So you could use a keybinding and "commandline" for HBRun
 
May 20, 2008
11,045
90
Syracuse, NY, USA
A UNIX trick. "Cal" is a good example (thanks, Joe). A Terminal keybinding like this

Code:
{ "command": { "action": "splitPane", "split": "auto", "commandline": "c:\\windows\\system32\\wsl.exe cal -3 ; read -n1"}, "keys": "ctrl+shift+b" },

will give a 3-month calendar in a suitably split pane. The pane will close after any keystroke, including Escape.

"Read" is apparently the way to emulate TCC's PAUSE or INPUT in bash.
 
May 20, 2008
11,045
90
Syracuse, NY, USA
Print the current date/time and hide the cursor too ...
Code:
"commandline": "c:\\windows\\system32\\wsl.exe cal -3 ; echo $(date) ; tput civis ; read -n1"