Add WSL support for usage terminal commands

Run ccusage commands through bash -ic in WSL to properly load shell environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
andrepimenta
2025-12-06 12:55:44 +00:00
parent 2e640fa20a
commit 97920395d1

View File

@@ -2716,17 +2716,29 @@ class ClaudeChatProvider {
}
private _openUsageTerminal(usageType: string): void {
// Get WSL configuration
const config = vscode.workspace.getConfiguration('claudeCodeChat');
const wslEnabled = config.get<boolean>('wsl.enabled', false);
const wslDistro = config.get<string>('wsl.distro', 'Ubuntu');
const terminal = vscode.window.createTerminal({
name: 'Claude Usage',
location: { viewColumn: vscode.ViewColumn.One }
});
let command: string;
if (usageType === 'plan') {
// Plan users get live usage view
terminal.sendText('npx -y ccusage blocks --live');
command = 'npx -y ccusage blocks --live';
} else {
// API users get recent usage history
terminal.sendText('npx -y ccusage blocks --recent --order desc');
command = 'npx -y ccusage blocks --recent --order desc';
}
if (wslEnabled) {
terminal.sendText(`wsl -d ${wslDistro} bash -ic "${command}"`);
} else {
terminal.sendText(command);
}
terminal.show();