@@ -2,11 +2,19 @@ import * as vscode from "vscode"
22import pWaitFor from "p-wait-for"
33import { ExitCodeDetails , mergePromise , TerminalProcess , TerminalProcessResultPromise } from "./TerminalProcess"
44import { truncateOutput , applyRunLengthEncoding } from "../misc/extract-text"
5+ // Import TerminalRegistry here to avoid circular dependencies
6+ const { TerminalRegistry } = require ( "./TerminalRegistry" )
57
68export const TERMINAL_SHELL_INTEGRATION_TIMEOUT = 5000
79
810export class Terminal {
911 private static shellIntegrationTimeout : number = TERMINAL_SHELL_INTEGRATION_TIMEOUT
12+ private static commandDelay : number = 0
13+ private static powershellCounter : boolean = false
14+ private static terminalZshClearEolMark : boolean = true
15+ private static terminalZshOhMy : boolean = false
16+ private static terminalZshP10k : boolean = false
17+ private static terminalZdotdir : boolean = false
1018
1119 public terminal : vscode . Terminal
1220 public busy : boolean
@@ -180,10 +188,16 @@ export class Terminal {
180188 // Wait for shell integration before executing the command
181189 pWaitFor ( ( ) => this . terminal . shellIntegration !== undefined , { timeout : Terminal . shellIntegrationTimeout } )
182190 . then ( ( ) => {
191+ // Clean up temporary directory if shell integration is available, zsh did its job:
192+ TerminalRegistry . zshCleanupTmpDir ( this . id )
193+
194+ // Run the command in the terminal
183195 process . run ( command )
184196 } )
185197 . catch ( ( ) => {
186198 console . log ( `[Terminal ${ this . id } ] Shell integration not available. Command execution aborted.` )
199+ // Clean up temporary directory if shell integration is not available
200+ TerminalRegistry . zshCleanupTmpDir ( this . id )
187201 process . emit (
188202 "no_shell_integration" ,
189203 `Shell integration initialization sequence '\\x1b]633;A' was not received within ${ Terminal . shellIntegrationTimeout / 1000 } s. Shell integration has been disabled for this terminal instance. Increase the timeout in the settings if necessary.` ,
@@ -256,7 +270,107 @@ export class Terminal {
256270 Terminal . shellIntegrationTimeout = timeoutMs
257271 }
258272
273+ public static getShellIntegrationTimeout ( ) : number {
274+ return Terminal . shellIntegrationTimeout
275+ }
276+
277+ /**
278+ * Sets the command delay in milliseconds
279+ * @param delayMs The delay in milliseconds
280+ */
281+ public static setCommandDelay ( delayMs : number ) : void {
282+ Terminal . commandDelay = delayMs
283+ }
284+
285+ /**
286+ * Gets the command delay in milliseconds
287+ * @returns The command delay in milliseconds
288+ */
289+ public static getCommandDelay ( ) : number {
290+ return Terminal . commandDelay
291+ }
292+
293+ /**
294+ * Sets whether to use the PowerShell counter workaround
295+ * @param enabled Whether to enable the PowerShell counter workaround
296+ */
297+ public static setPowershellCounter ( enabled : boolean ) : void {
298+ Terminal . powershellCounter = enabled
299+ }
300+
301+ /**
302+ * Gets whether to use the PowerShell counter workaround
303+ * @returns Whether the PowerShell counter workaround is enabled
304+ */
305+ public static getPowershellCounter ( ) : boolean {
306+ return Terminal . powershellCounter
307+ }
308+
309+ /**
310+ * Sets whether to clear the ZSH EOL mark
311+ * @param enabled Whether to clear the ZSH EOL mark
312+ */
313+ public static setTerminalZshClearEolMark ( enabled : boolean ) : void {
314+ Terminal . terminalZshClearEolMark = enabled
315+ }
316+
317+ /**
318+ * Gets whether to clear the ZSH EOL mark
319+ * @returns Whether the ZSH EOL mark clearing is enabled
320+ */
321+ public static getTerminalZshClearEolMark ( ) : boolean {
322+ return Terminal . terminalZshClearEolMark
323+ }
324+
325+ /**
326+ * Sets whether to enable Oh My Zsh shell integration
327+ * @param enabled Whether to enable Oh My Zsh shell integration
328+ */
329+ public static setTerminalZshOhMy ( enabled : boolean ) : void {
330+ Terminal . terminalZshOhMy = enabled
331+ }
332+
333+ /**
334+ * Gets whether Oh My Zsh shell integration is enabled
335+ * @returns Whether Oh My Zsh shell integration is enabled
336+ */
337+ public static getTerminalZshOhMy ( ) : boolean {
338+ return Terminal . terminalZshOhMy
339+ }
340+
341+ /**
342+ * Sets whether to enable Powerlevel10k shell integration
343+ * @param enabled Whether to enable Powerlevel10k shell integration
344+ */
345+ public static setTerminalZshP10k ( enabled : boolean ) : void {
346+ Terminal . terminalZshP10k = enabled
347+ }
348+
349+ /**
350+ * Gets whether Powerlevel10k shell integration is enabled
351+ * @returns Whether Powerlevel10k shell integration is enabled
352+ */
353+ public static getTerminalZshP10k ( ) : boolean {
354+ return Terminal . terminalZshP10k
355+ }
356+
259357 public static compressTerminalOutput ( input : string , lineLimit : number ) : string {
260358 return truncateOutput ( applyRunLengthEncoding ( input ) , lineLimit )
261359 }
360+
361+ /**
362+ * Sets whether to enable ZDOTDIR handling for zsh
363+ * @param enabled Whether to enable ZDOTDIR handling
364+ */
365+ public static setTerminalZdotdir ( enabled : boolean ) : void {
366+ Terminal . terminalZdotdir = enabled
367+ }
368+
369+ /**
370+ * Gets whether ZDOTDIR handling is enabled
371+ * @returns Whether ZDOTDIR handling is enabled
372+ */
373+ public static getTerminalZdotdir ( ) : boolean {
374+ return Terminal . terminalZdotdir
375+ }
262376}
0 commit comments