Skip to content

Commit 527766a

Browse files
committed
fix: disable auto correct for zsh shells
1 parent 3c5d5db commit 527766a

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codifycli/plugin-core",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "TypeScript library for building Codify plugins to manage system resources (applications, CLI tools, settings) through infrastructure-as-code",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/pty/background-pty.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ export class BackgroundPty implements IPty {
135135
return new Promise(resolve => {
136136
this.basePty.write(' unset PS1;\n');
137137
this.basePty.write(' unset PS0;\n')
138+
// zsh autocorrect prompts (e.g. "zsh: correct 'config' to '.config' [nyae]?") will hang
139+
// the pty waiting for interactive input. Can't be disabled via env var; must unset the options explicitly.
140+
this.basePty.write(' unsetopt CORRECT CORRECT_ALL 2>/dev/null; true;\n')
138141
this.basePty.write(' echo setup complete\\"\n')
139142

140143
const listener = this.basePty.onData((data: string) => {

src/pty/seqeuntial-pty.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ export class SequentialPty implements IPty {
8888
const initialCols = options?.disableWrapping ? 10_000 : process.stdout.columns ?? 80
8989
const initialRows = process.stdout.rows ?? 24;
9090

91-
const args = options?.interactive ? ['-i', '-c', cmd] : ['-c', cmd]
91+
// zsh autocorrect prompts (e.g. "zsh: correct 'config' to '.config' [nyae]?") will hang
92+
// the pty waiting for interactive input. Can't be disabled via env var; must unset the options explicitly.
93+
const disableAutocorrect = Utils.getShell() === Shell.ZSH ? 'unsetopt CORRECT CORRECT_ALL 2>/dev/null; ' : '';
94+
const wrappedCmd = `${disableAutocorrect}${cmd}`;
95+
const args = options?.interactive ? ['-i', '-c', wrappedCmd] : ['-c', wrappedCmd]
9296

9397
// Run the command in a pty for interactivity
9498
const mPty = pty.spawn(this.getDefaultShell(), args, {

0 commit comments

Comments
 (0)