@vscode-utility/terminal-browserify
v1.0.5
Published
The `terminal` module compatible for VS Code Web Extensions
Downloads
43
Maintainers
Readme
@vscode-utility/terminal-browserify
Easily build VS Code extensions that work seamlessly on both desktop and web (https://vscode.dev, https://github.dev). This package provides a unified API for terminal management and file system operations, allowing you to create, control, and customize terminals, as well as access files in both local and remote environments. Simplify cross-platform extension development with utilities designed for compatibility, flexibility, and ease of use.
If you find this package useful for your projects, please consider supporting me by Github, Patreon, KO-FI or Paypal. It's a great way to help me maintain and improve this tool in the future. Your support is truly appreciated!
Installation
npm
npm install @vscode-utility/terminal-browserifyyarn
yarn add @vscode-utility/terminal-browserifypnpm
pnpm add @vscode-utility/terminal-browserifyUsage
import { TerminalApi, ThemeService } from '@vscode-utility/terminal-browserify';
// --- TerminalApi usage ---
// Get the singleton instance of TerminalApi
const terminalApi = TerminalApi.instance();
// Create a new terminal
const themeService = new ThemeService();
const terminalItem = { name: 'My Terminal', commands: ['echo Hello World'] };
const terminal = terminalApi.createTerminal(themeService, terminalItem, { kind: 'standalone' }, false);
// Get absolute path for cwd
const cwdPath = await terminalApi.getCwdPath('./my-folder');
// Check if a terminal exists by name
const exists = terminalApi.isTerminalExist('My Terminal');
// Get the command join operator for the current OS
const joinOp = terminalApi.getJoinOperator();
// Get the list of current terminals
const terminals = terminalApi.getCurrentTerminals();
// Focus the terminal with focus=true in the list
terminalApi.focusTerminal([{ name: 'My Terminal', focus: true }]);
// Kill all terminals (and kill process if needed)
await terminalApi.killAllTerminalAsync(true);
// --- ThemeService usage ---
// Create a ThemeService instance with a specific theme
const themeService = new ThemeService('chaos'); // or 'default', 'inkwell', etc.
// Get a ThemeColor for a terminal
const color = themeService.getColor(undefined, 'groupName', 'terminalName');
// Get a ThemeIcon for a terminal
const icon = themeService.getIcon(undefined, 'groupName', 'terminalName');
// Get a session icon by session name (static method)
const sessionIcon = ThemeService.getSessionIcon('my-session');Feedback
If you discover a bug, or have a suggestion for a feature request, please submit an issue.
LICENSE
This extension is licensed under the MIT License
