Skip to content

Commit b4c67f1

Browse files
author
Eric Wheeler
committed
feat: add terminal settings for Oh My Zsh and Powerlevel10k shell integration
Added two new terminal settings: - terminalZshOhMy: Sets ITERM_SHELL_INTEGRATION_INSTALLED=Yes for Oh My Zsh - terminalZshP10k: Sets POWERLEVEL9K_TERM_SHELL_INTEGRATION=true for Powerlevel10k Signed-off-by: Eric Wheeler <[email protected]>
1 parent b020e46 commit b4c67f1

28 files changed

+280
-1
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
357357
terminalShellIntegrationTimeout,
358358
terminalCommandDelay,
359359
terminalZshClearEolMark,
360+
terminalZshOhMy,
361+
terminalZshP10k,
360362
terminalPowershellCounter,
361363
}) => {
362364
setSoundEnabled(soundEnabled ?? false)
@@ -365,6 +367,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
365367
)
366368
Terminal.setCommandDelay(terminalCommandDelay ?? 0)
367369
Terminal.setTerminalZshClearEolMark(terminalZshClearEolMark ?? true)
370+
Terminal.setTerminalZshOhMy(terminalZshOhMy ?? false)
371+
Terminal.setTerminalZshP10k(terminalZshP10k ?? false)
368372
Terminal.setPowershellCounter(terminalPowershellCounter ?? false)
369373
},
370374
)
@@ -1213,6 +1217,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12131217
terminalCommandDelay,
12141218
terminalPowershellCounter,
12151219
terminalZshClearEolMark,
1220+
terminalZshOhMy,
1221+
terminalZshP10k,
12161222
fuzzyMatchThreshold,
12171223
mcpEnabled,
12181224
enableMcpServerCreation,
@@ -1283,6 +1289,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
12831289
terminalCommandDelay: terminalCommandDelay ?? 0,
12841290
terminalPowershellCounter: terminalPowershellCounter ?? false,
12851291
terminalZshClearEolMark: terminalZshClearEolMark ?? true,
1292+
terminalZshOhMy: terminalZshOhMy ?? false,
1293+
terminalZshP10k: terminalZshP10k ?? false,
12861294
fuzzyMatchThreshold: fuzzyMatchThreshold ?? 1.0,
12871295
mcpEnabled: mcpEnabled ?? true,
12881296
enableMcpServerCreation: enableMcpServerCreation ?? true,
@@ -1372,6 +1380,8 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
13721380
terminalCommandDelay: stateValues.terminalCommandDelay ?? 0,
13731381
terminalPowershellCounter: stateValues.terminalPowershellCounter ?? false,
13741382
terminalZshClearEolMark: stateValues.terminalZshClearEolMark ?? true,
1383+
terminalZshOhMy: stateValues.terminalZshOhMy ?? false,
1384+
terminalZshP10k: stateValues.terminalZshP10k ?? false,
13751385
mode: stateValues.mode ?? defaultModeSlug,
13761386
language: stateValues.language ?? formatLanguage(vscode.env.language),
13771387
mcpEnabled: stateValues.mcpEnabled ?? true,

src/core/webview/webviewMessageHandler.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,20 @@ export const webviewMessageHandler = async (provider: ClineProvider, message: We
757757
Terminal.setTerminalZshClearEolMark(message.bool)
758758
}
759759
break
760+
case "terminalZshOhMy":
761+
await updateGlobalState("terminalZshOhMy", message.bool)
762+
await provider.postStateToWebview()
763+
if (message.bool !== undefined) {
764+
Terminal.setTerminalZshOhMy(message.bool)
765+
}
766+
break
767+
case "terminalZshP10k":
768+
await updateGlobalState("terminalZshP10k", message.bool)
769+
await provider.postStateToWebview()
770+
if (message.bool !== undefined) {
771+
Terminal.setTerminalZshP10k(message.bool)
772+
}
773+
break
760774
case "mode":
761775
await provider.handleModeSwitch(message.text as Mode)
762776
break

src/exports/roo-code.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ type GlobalSettings = {
269269
terminalCommandDelay?: number | undefined
270270
terminalPowershellCounter?: boolean | undefined
271271
terminalZshClearEolMark?: boolean | undefined
272+
terminalZshOhMy?: boolean | undefined
273+
terminalZshP10k?: boolean | undefined
272274
rateLimitSeconds?: number | undefined
273275
diffEnabled?: boolean | undefined
274276
fuzzyMatchThreshold?: number | undefined

src/exports/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ type GlobalSettings = {
272272
terminalCommandDelay?: number | undefined
273273
terminalPowershellCounter?: boolean | undefined
274274
terminalZshClearEolMark?: boolean | undefined
275+
terminalZshOhMy?: boolean | undefined
276+
terminalZshP10k?: boolean | undefined
275277
rateLimitSeconds?: number | undefined
276278
diffEnabled?: boolean | undefined
277279
fuzzyMatchThreshold?: number | undefined

src/integrations/terminal/Terminal.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export class Terminal {
1010
private static commandDelay: number = 0
1111
private static powershellCounter: boolean = false
1212
private static terminalZshClearEolMark: boolean = true
13+
private static terminalZshOhMy: boolean = false
14+
private static terminalZshP10k: boolean = false
1315

1416
public terminal: vscode.Terminal
1517
public busy: boolean
@@ -311,6 +313,38 @@ export class Terminal {
311313
return Terminal.terminalZshClearEolMark
312314
}
313315

316+
/**
317+
* Sets whether to enable Oh My Zsh shell integration
318+
* @param enabled Whether to enable Oh My Zsh shell integration
319+
*/
320+
public static setTerminalZshOhMy(enabled: boolean): void {
321+
Terminal.terminalZshOhMy = enabled
322+
}
323+
324+
/**
325+
* Gets whether Oh My Zsh shell integration is enabled
326+
* @returns Whether Oh My Zsh shell integration is enabled
327+
*/
328+
public static getTerminalZshOhMy(): boolean {
329+
return Terminal.terminalZshOhMy
330+
}
331+
332+
/**
333+
* Sets whether to enable Powerlevel10k shell integration
334+
* @param enabled Whether to enable Powerlevel10k shell integration
335+
*/
336+
public static setTerminalZshP10k(enabled: boolean): void {
337+
Terminal.terminalZshP10k = enabled
338+
}
339+
340+
/**
341+
* Gets whether Powerlevel10k shell integration is enabled
342+
* @returns Whether Powerlevel10k shell integration is enabled
343+
*/
344+
public static getTerminalZshP10k(): boolean {
345+
return Terminal.terminalZshP10k
346+
}
347+
314348
public static compressTerminalOutput(input: string, lineLimit: number): string {
315349
return truncateOutput(applyRunLengthEncoding(input), lineLimit)
316350
}

src/integrations/terminal/TerminalRegistry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ export class TerminalRegistry {
117117
VTE_VERSION: "0",
118118
}
119119

120+
// Set Oh My Zsh shell integration if enabled
121+
if (Terminal.getTerminalZshOhMy()) {
122+
env.ITERM_SHELL_INTEGRATION_INSTALLED = "Yes"
123+
}
124+
125+
// Set Powerlevel10k shell integration if enabled
126+
if (Terminal.getTerminalZshP10k()) {
127+
env.POWERLEVEL9K_TERM_SHELL_INTEGRATION = "true"
128+
}
129+
120130
// VSCode bug#237208: Command output can be lost due to a race between completion
121131
// sequences and consumers. Add delay via PROMPT_COMMAND to ensure the
122132
// \x1b]633;D escape sequence arrives after command output is processed.

src/integrations/terminal/__tests__/TerminalRegistry.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,47 @@ describe("TerminalRegistry", () => {
6262
Terminal.setCommandDelay(originalDelay)
6363
}
6464
})
65+
66+
it("adds Oh My Zsh integration env var when enabled", () => {
67+
Terminal.setTerminalZshOhMy(true)
68+
try {
69+
TerminalRegistry.createTerminal("/test/path")
70+
71+
expect(mockCreateTerminal).toHaveBeenCalledWith({
72+
cwd: "/test/path",
73+
name: "Roo Code",
74+
iconPath: expect.any(Object),
75+
env: {
76+
PAGER: "cat",
77+
VTE_VERSION: "0",
78+
PROMPT_EOL_MARK: "",
79+
ITERM_SHELL_INTEGRATION_INSTALLED: "Yes",
80+
},
81+
})
82+
} finally {
83+
Terminal.setTerminalZshOhMy(false)
84+
}
85+
})
86+
87+
it("adds Powerlevel10k integration env var when enabled", () => {
88+
Terminal.setTerminalZshP10k(true)
89+
try {
90+
TerminalRegistry.createTerminal("/test/path")
91+
92+
expect(mockCreateTerminal).toHaveBeenCalledWith({
93+
cwd: "/test/path",
94+
name: "Roo Code",
95+
iconPath: expect.any(Object),
96+
env: {
97+
PAGER: "cat",
98+
VTE_VERSION: "0",
99+
PROMPT_EOL_MARK: "",
100+
POWERLEVEL9K_TERM_SHELL_INTEGRATION: "true",
101+
},
102+
})
103+
} finally {
104+
Terminal.setTerminalZshP10k(false)
105+
}
106+
})
65107
})
66108
})

src/schemas/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ export const globalSettingsSchema = z.object({
535535
terminalCommandDelay: z.number().optional(),
536536
terminalPowershellCounter: z.boolean().optional(),
537537
terminalZshClearEolMark: z.boolean().optional(),
538+
terminalZshOhMy: z.boolean().optional(),
539+
terminalZshP10k: z.boolean().optional(),
538540

539541
rateLimitSeconds: z.number().optional(),
540542
diffEnabled: z.boolean().optional(),
@@ -608,6 +610,8 @@ const globalSettingsRecord: GlobalSettingsRecord = {
608610
terminalCommandDelay: undefined,
609611
terminalPowershellCounter: undefined,
610612
terminalZshClearEolMark: undefined,
613+
terminalZshOhMy: undefined,
614+
terminalZshP10k: undefined,
611615

612616
rateLimitSeconds: undefined,
613617
diffEnabled: undefined,

src/shared/ExtensionMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ export type ExtensionState = Pick<
156156
| "terminalCommandDelay"
157157
| "terminalPowershellCounter"
158158
| "terminalZshClearEolMark"
159+
| "terminalZshOhMy"
160+
| "terminalZshP10k"
159161
| "diffEnabled"
160162
| "fuzzyMatchThreshold"
161163
// | "experiments" // Optional in GlobalSettings, required here.

src/shared/WebviewMessage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export interface WebviewMessage {
8585
| "terminalCommandDelay"
8686
| "terminalPowershellCounter"
8787
| "terminalZshClearEolMark"
88+
| "terminalZshOhMy"
89+
| "terminalZshP10k"
8890
| "mcpEnabled"
8991
| "enableMcpServerCreation"
9092
| "searchCommits"

0 commit comments

Comments
 (0)