mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 13:10:43 +00:00
Support --locate-shell-integration-path in server CLI (#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
This commit is contained in:
parent
ba6088a21a
commit
ac4d678fb9
2 changed files with 15 additions and 6 deletions
|
@ -63,10 +63,6 @@ export async function main(argv: string[]): Promise<any> {
|
|||
|
||||
// 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)"`
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue