Shell integration CLI progress

This commit is contained in:
Daniel Imms
2022-07-12 12:56:42 -07:00
parent 8f4d1a97f3
commit e0e5339bf7
4 changed files with 23 additions and 2 deletions
+19
View File
@@ -24,6 +24,8 @@ import product from 'vs/platform/product/common/product';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { randomPath } from 'vs/base/common/extpath';
import { Utils } from 'vs/platform/profiling/common/profiling';
import { dirname } from 'vs/base/common/resources';
import { FileAccess } from 'vs/base/common/network';
function shouldSpawnCliProcess(argv: NativeParsedArgs): boolean {
return !!argv['install-source']
@@ -59,6 +61,23 @@ export async function main(argv: string[]): Promise<any> {
console.log(buildVersionMessage(product.version, product.commit));
}
// Shell integration
else if (args['shell-integration']) {
// Silently fail when the terminal is not VS Code's integrated terminal
if (process.env['TERM_PROGRAM'] !== 'vscode') {
return;
}
let p: string;
switch (args['shell-integration']) {
case 'bash': p = 'vs\\workbench\\contrib\\terminal\\browser\\media\\shellIntegration-bash.sh'; break;
// Usage: if ($s=$(code --shell-integration pwsh)) { . $s }
case 'pwsh': p = 'vs\\workbench\\contrib\\terminal\\browser\\media\\shellIntegration.ps1'; break;
case 'zsh': p = 'vs\\workbench\\contrib\\terminal\\browser\\media\\shellIntegration-rc.zsh'; break;
default: throw new Error('Error using --shell-integration: Invalid shell type');
}
console.log(`${dirname(FileAccess.asFileUri('', require)).fsPath}\\out\\${p}`);
}
// Extensions Management
else if (shouldSpawnCliProcess(args)) {
const cli = await new Promise<IMainCli>((resolve, reject) => require(['vs/code/node/cliProcessMain'], resolve, reject));