-
Notifications
You must be signed in to change notification settings - Fork 522
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all issues to ensure it has not already been reported.
Summary
Unlike existing issue #1470 which asks for the ability to pass parameters to powershell.exe, I'd like the ability to pass PowerShell command(s) to whatever PowerShell version is used behind the scenes by the extension.
For the VS Code built in terminals, but also in Windows Terminal, I like to add following command at startup to quickly be able to identify what PowerShell version is used:
"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})"For VSCode integrated terminals I add the following in settings.json:
Click to view
"terminal.integrated.profiles.windows": {
"PowerShell Microsoft Store": {
"args": [
"/NoLogo",
"/NoExit",
"/NoProfile",
"/ExecutionPolicy",
"RemoteSigned",
"/Command",
"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})"
],
"icon": "terminal-powershell",
"overrideName": true,
"path": "${env:LOCALAPPDATA}\\Microsoft\\WindowsApps\\Microsoft.PowerShell_8wekyb3d8bbwe\\pwsh.exe"
},
"Windows PowerShell (x64)": {
"args": [
"/NoLogo",
"/NoExit",
"/NoProfile",
"/ExecutionPolicy",
"RemoteSigned",
"/Command",
"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})"
],
"overrideName": true,
"path": "${env:SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"Windows PowerShell (x86)": {
"args": [
"/NoLogo",
"/NoExit",
"/NoProfile",
"/ExecutionPolicy",
"RemoteSigned",
"/Command",
"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})"
],
"icon": "terminal-powershell",
"overrideName": true,
"path": "${env:SystemRoot}\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"
}
}For Windows Terminal it can be done like so:
Click to view
...
"profiles":
{
...
"list":
[
...
{
"commandline": "\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" /NoLogo /NoExit /Command \"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})\"",
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "Windows PowerShell x64"
},
{
"commandline": "\"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\Microsoft.PowerShell_8wekyb3d8bbwe\\pwsh.exe\" /NoLogo /NoExit /Command \"'v{0} x{1}' -f $PSVersionTable.PSVersion.ToString(),$(if([System.Environment]::Is64BitProcess){'64'}else{'86'})\"",
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell Microsoft Store",
"source": "Windows.Terminal.PowershellCore"
},
...
]
}
...Proposed Design
A similar config.json settings for the PowerShell extension would be nice. Something like powershell.integratedConsole.startupCommand maybe?
- If
powershell.integratedConsole.startupCommandis defined and has a value:<powershell/pwsh>.exe /Command <value_of_powershell.integratedConsole.startupCommand>