diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts index c64e6fe0503..3a006e635a3 100644 --- a/src/vs/code/node/cli.ts +++ b/src/vs/code/node/cli.ts @@ -63,10 +63,6 @@ export async function main(argv: string[]): Promise { // Shell integration else if (args['locate-shell-integration-path']) { - // Silently fail when the terminal is not VS Code's integrated terminal - if (process.env['TERM_PROGRAM'] !== 'vscode') { - return; - } let file: string; switch (args['locate-shell-integration-path']) { // Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"` diff --git a/src/vs/server/node/server.cli.ts b/src/vs/server/node/server.cli.ts index 4c5ec7e1e2a..837b0b500d4 100644 --- a/src/vs/server/node/server.cli.ts +++ b/src/vs/server/node/server.cli.ts @@ -44,7 +44,6 @@ const isSupportedForCmd = (optionId: keyof RemoteParsedArgs) => { case 'enable-smoke-test-driver': case 'extensions-download-dir': case 'builtin-extensions-dir': - case 'locate-shell-integration-path': case 'telemetry': return false; default: @@ -74,6 +73,7 @@ const isSupportedForPipe = (optionId: keyof RemoteParsedArgs) => { case 'category': case 'verbose': case 'remote': + case 'locate-shell-integration-path': return true; default: return false; @@ -135,6 +135,20 @@ export function main(desc: ProductDescription, args: string[]): void { console.log(buildVersionMessage(desc.version, desc.commit)); return; } + if (parsedArgs['locate-shell-integration-path']) { + let file: string; + switch (parsedArgs['locate-shell-integration-path']) { + // Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"` + case 'bash': file = 'shellIntegration-bash.sh'; break; + // Usage: `if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }` + case 'pwsh': file = 'shellIntegration.ps1'; break; + // Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"` + case 'zsh': file = 'shellIntegration-rc.zsh'; break; + default: throw new Error('Error using --locate-shell-integration-path: Invalid shell type'); + } + console.log(resolve(__dirname, '../..', 'workbench', 'contrib', 'terminal', 'browser', 'media', file)); + return; + } if (cliPipe) { if (parsedArgs['openExternal']) { openInBrowser(parsedArgs['_'], verbose); @@ -218,7 +232,6 @@ export function main(desc: ProductDescription, args: string[]): void { return; } - const newCommandline: string[] = []; for (const key in parsedArgs) { const val = parsedArgs[key as keyof typeof parsedArgs];