I'm currently using Windows Terminal with PowerShell, and I wanted to find a solution for remembering the different terminals created between sessions, as the internal Visual Studio command-line tool doesn't provide this functionality (If it does, I'm all ears :))
To achieve this, I attempted to build a script in Windows Terminal that would create a new tab and split it into three sections, each with a different root. Here's the script I tried alongside the error log :
$frontendPath = "C:\Path_Example\frontend"
$backendPath = "C:\Path_Example\backend"
$rootPath = "C:\Path_Example"
$command = "wt ; split-pane -p 'pwsh -NoExit -Command `""cd '$frontendPath'; pwsh`""" +
" ; split-pane -H -p 'pwsh -NoExit -Command `""cd '$backendPath'; pwsh`""" +
" ; split-pane -H -p 'pwsh -NoExit -Command `""cd '$rootPath'; pwsh`"""
Start-Process -FilePath wt.exe -ArgumentList "-d", ".", "-e", $command
At C:\Users\speak\split.ps1:5 char:58
+ $command = "wt ; split-pane -p 'pwsh -NoExit -Command `""cd '$fronten ...
+ ~~
Unexpected token 'cd' in expression or statement.
At C:\Users\speak\split.ps1:6 char:59
+ " ; split-pane -H -p 'pwsh -NoExit -Command `""cd '$backen ...
+ ~~
Unexpected token 'cd' in expression or statement.
At C:\Users\speak\split.ps1:7 char:59
+ " ; split-pane -H -p 'pwsh -NoExit -Command `""cd '$rootPa ...
+ ~~
Unexpected token 'cd' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
As you can see, I'm not very experienced with scripting, so I sought help from ChatGPT. Unfortunately, despite trying different prompts, I haven't been able to resolve the issue. If anyone could provide some guidance or help me troubleshoot, I would greatly appreciate it.
Thanks a lot.