Skip to content

Commit ac4d678

Browse files
authored
Support --locate-shell-integration-path in server CLI (microsoft#155870)
* Fix shell-integration remote cli * Don't silently fail based on TERM_PROGRAM We want this to work even in terminals where TERM_PROGRAM may not exist, such as in a regular ssh session. The manual install recommends using an if before sourcing anyway. * Handle shell integration option on server cli * Move shell integration option handling higher
1 parent ba6088a commit ac4d678

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/vs/code/node/cli.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ export async function main(argv: string[]): Promise<any> {
6363

6464
// Shell integration
6565
else if (args['locate-shell-integration-path']) {
66-
// Silently fail when the terminal is not VS Code's integrated terminal
67-
if (process.env['TERM_PROGRAM'] !== 'vscode') {
68-
return;
69-
}
7066
let file: string;
7167
switch (args['locate-shell-integration-path']) {
7268
// Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"`

src/vs/server/node/server.cli.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const isSupportedForCmd = (optionId: keyof RemoteParsedArgs) => {
4444
case 'enable-smoke-test-driver':
4545
case 'extensions-download-dir':
4646
case 'builtin-extensions-dir':
47-
case 'locate-shell-integration-path':
4847
case 'telemetry':
4948
return false;
5049
default:
@@ -74,6 +73,7 @@ const isSupportedForPipe = (optionId: keyof RemoteParsedArgs) => {
7473
case 'category':
7574
case 'verbose':
7675
case 'remote':
76+
case 'locate-shell-integration-path':
7777
return true;
7878
default:
7979
return false;
@@ -135,6 +135,20 @@ export function main(desc: ProductDescription, args: string[]): void {
135135
console.log(buildVersionMessage(desc.version, desc.commit));
136136
return;
137137
}
138+
if (parsedArgs['locate-shell-integration-path']) {
139+
let file: string;
140+
switch (parsedArgs['locate-shell-integration-path']) {
141+
// Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path bash)"`
142+
case 'bash': file = 'shellIntegration-bash.sh'; break;
143+
// Usage: `if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }`
144+
case 'pwsh': file = 'shellIntegration.ps1'; break;
145+
// Usage: `[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"`
146+
case 'zsh': file = 'shellIntegration-rc.zsh'; break;
147+
default: throw new Error('Error using --locate-shell-integration-path: Invalid shell type');
148+
}
149+
console.log(resolve(__dirname, '../..', 'workbench', 'contrib', 'terminal', 'browser', 'media', file));
150+
return;
151+
}
138152
if (cliPipe) {
139153
if (parsedArgs['openExternal']) {
140154
openInBrowser(parsedArgs['_'], verbose);
@@ -218,7 +232,6 @@ export function main(desc: ProductDescription, args: string[]): void {
218232
return;
219233
}
220234

221-
222235
const newCommandline: string[] = [];
223236
for (const key in parsedArgs) {
224237
const val = parsedArgs[key as keyof typeof parsedArgs];

0 commit comments

Comments
 (0)