shellwise 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shellwise",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Smart command history with inline auto-suggest and fuzzy search for your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,5 @@
1
1
  import { openSync, writeSync, closeSync } from "fs";
2
+ import { execSync } from "child_process";
2
3
 
3
4
  const ESC = "\x1b[";
4
5
 
@@ -49,10 +50,14 @@ export function showCursor(): string {
49
50
  }
50
51
 
51
52
  export function getTerminalSize(): { rows: number; cols: number } {
52
- // process.stdout may not be a TTY when running inside $() capture
53
- const rows = process.stdout?.rows || process.stderr?.rows || 24;
54
- const cols = process.stdout?.columns || process.stderr?.columns || 80;
55
- return { rows, cols };
53
+ // Avoid process.stdout/stderr entirely Bun crashes with kqueue error
54
+ // when they're accessed inside $() capture. Use stty instead.
55
+ try {
56
+ const output = execSync("stty size </dev/tty", { encoding: "utf-8" }).trim();
57
+ const [rows, cols] = output.split(" ").map(Number);
58
+ if (rows > 0 && cols > 0) return { rows, cols };
59
+ } catch {}
60
+ return { rows: 24, cols: 80 };
56
61
  }
57
62
 
58
63
  export function write(text: string): void {