Closed as not planned
Description
Update:
for anyone encounter the same problem:
I suggest to set envrionment variables in Windows Terminal, and do not set env vars in script and let wt inherit it.
If you use powershell script, here is my solution:
$pre_cmd_string = {
# do common pre run setup, set env vars, run some commands, etc...
# DO NOT WRITE ANY COMMENTS IN THIS BLOCK, AND REMEMBER REMOVE US TOO
}.ToString()
<# prepare first pane...#>
$first_cmd_string = $pre_cmd_string + "`n" + { <#per pane setup code#> }.ToString()
$first_cmd_bytes = [System.Text.Encoding]::Unicode.GetBytes( $first_cmd_string )
$first_cmd_enc = [Convert]::ToBase64String( $first_cmd_bytes )
<# ... and #>
<# prepare rest of panes as above...#>
<# launching wt and launching powershell with EncodedCommand parm #>
wt pwsh.exe -ExecutionPolicy ByPass -NoExit -EncodedCommand $first_cmd_enc
Windows Terminal version
1.18.1421.0
Windows build number
10.0.19045.0
Other Software
PowerShell 7.4
Steps to reproduce
openopen a standalonepowershell
powershell
commandline window (not inwt
window)- custom a env var
$Env:MY_VAR="MY_VAL"
- launch a new Windows Terminal
wt
- in new window (running powershell), type
echo $Env:MY_VAR
- Nothing show up
after I disable compatibility.reloadEnvironmentVariables
in global settings.json
, new wt window inherit env var set in powershell
Expected Behavior
No response
Actual Behavior
see above