mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Add terminal profile example
This commit is contained in:
@ -19,10 +19,12 @@ This sample provides several commands that demonstrates how to utilize the integ
|
||||
|
||||
- `window.createTerminalRenderer`
|
||||
- `window.TerminalRenderer`
|
||||
- `window.registerTerminalProfileProvider`
|
||||
|
||||
### Contribution Points
|
||||
|
||||
- [`contributes.commands`](https://code.visualstudio.com/api/references/contribution-points#contributes.commands)
|
||||
- [`contributes.terminal`](https://code.visualstudio.com/updates/v1_57#_terminal-profile-contributions)
|
||||
|
||||
## Running the Sample
|
||||
|
||||
|
||||
@ -35,7 +35,8 @@
|
||||
"onCommand:terminalTest.showPreserveFocus",
|
||||
"onCommand:terminalTest.terminals",
|
||||
"onCommand:terminalTest.updateEnvironment",
|
||||
"onCommand:terminalTest.clearEnvironment"
|
||||
"onCommand:terminalTest.clearEnvironment",
|
||||
"onTerminalProfile:terminalTest.profile"
|
||||
],
|
||||
"main": "./out/extension.js",
|
||||
"contributes": {
|
||||
@ -112,7 +113,16 @@
|
||||
"command": "terminalTest.registerTerminalLinkProvider",
|
||||
"title": "Terminal API: Register link provider"
|
||||
}
|
||||
]
|
||||
],
|
||||
"terminal": {
|
||||
"profiles": [
|
||||
{
|
||||
"id": "terminalTest.profile",
|
||||
"icon": "terminal",
|
||||
"title": "Terminal API Profile"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
|
||||
@ -180,6 +180,15 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.window.registerTerminalProfileProvider('terminalTest.profile', {
|
||||
provideProfileOptions(token: vscode.CancellationToken): vscode.ProviderResult<vscode.TerminalOptions> {
|
||||
return {
|
||||
name: 'Terminal API Profile',
|
||||
shellPath: process.env.shell || 'C:/Windows/System32/cmd.exe'
|
||||
};
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
function colorText(text: string): string {
|
||||
|
||||
Reference in New Issue
Block a user