Launch configured commands for files by extension.
This extension is built with:
- TypeScript
- esbuild
- ESLint + Prettier
- Command contribution starter
Extension Launcher
This extension includes a command named Extension Launcher that lets you:
- Pick a configured mapping (title + extension + command).
- List files in the workspace that match that extension.
- Select one file.
- Execute the configured command for that file.
It also adds an Explorer context-menu entry:
- Right-click a file in Explorer.
- Choose
Extension Launcher. - The extension matches mappings by the selected file extension.
- If one mapping matches, it runs immediately.
- If multiple mappings match, you choose from a quick pick.
Configure mappings in your VS Code settings:
"extensionLauncher.mappings": [
{
"title": "Open BCS In Editor",
"extension": ".bcs",
"command": "vscode.open",
"commandAvailability": "both"
},
{
"title": "Run Task: Process BCS File",
"extension": ".bcs",
"command": "workbench.action.tasks.runTask",
"commandAvailability": "contextMenu",
"commandArgs": ["Process Current BCS"]
},
{
"title": "Open Workspace Settings Search",
"extension": ".json",
"command": "workbench.action.openSettings",
"commandAvailability": "commandPalette",
"commandArgs": ["files.associations"]
},
{
"title": "Send File Info To Terminal",
"extension": ".bcs",
"command": "workbench.action.terminal.sendSequence",
"commandAvailability": "both",
"commandArgs": [
{
"text": "echo FILE=${fsPath} NAME=${basename} EXT=${extension}\u000D"
}
]
}
]
Control where the launcher is shown:
"extensionLauncher.commandAvailability": "both"
Allowed values:
both(default): show in Explorer context menu and Command Palette (F1).contextMenu: show only in Explorer context menu.commandPalette: show only in Command Palette (F1).
Per mapping, you can also set commandAvailability:
both(default): mapping is eligible from both Explorer context menu and Command Palette.contextMenu: mapping is eligible only from Explorer context menu launches.commandPalette: mapping is eligible only from Command Palette launches.
Behavior:
- Explorer context launch: if no mapping for that file extension is eligible for
both/contextMenu, nothing happens. - Command Palette launch: only mappings eligible for
both/commandPaletteare shown in subsequent selection menus.
Example notes:
vscode.open: omitcommandArgsso the selected fileUriis passed automatically.workbench.action.tasks.runTask: pass the task label exactly as defined in yourtasks.json.workbench.action.openSettings: useful when you want to jump to a specific setting query.workbench.action.terminal.sendSequence: uses a dedicated terminal named after the mappingtitle(reused if it already exists), then sends the sequence there.
commandArgs is optional.
- If
commandArgsis omitted, the selected file URI is passed automatically. - If provided, you can use tokens inside string arguments:
${uri}selected fileUriobject when used as a whole value, otherwise URI string when embedded in larger text${fsPath}absolute file path${path}URI path${basename}file name${dirname}parent path${extension}normalized extension from mapping
Run it with F1 -> Extension Launcher.
Development
Install dependencies:
npm install
Build once:
npm run build
Watch mode:
npm run watch
Type checking:
npm run typecheck
Lint:
npm run lint
Unit tests:
npm run test
Unit tests (watch mode):
npm run test:watch
Run/debug:
- Press
F5in VS Code to launch the Extension Development Host. - Run the command:
Extension Launcher.
Continuous Integration:
- GitHub Actions workflow at
.github/workflows/ci.ymlruns lint, typecheck, tests, and build on push and pull requests.
Packaging and Publishing
Before first publish, update metadata in package.json:
- Replace
publisher(your-publisher-name) with your real Marketplace publisher id. - Keep
displayName,description, andkeywordsaligned with what you want in search results.
Then sign in:
npx vsce login <publisher>
Create a VSIX package:
npm run package:vsix
Publish:
npm run publish:vsce