@giladbarnea/pi-pretty-bash 1.0.6 → 1.0.7

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.ts +9 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- last_updated: 2026-11-02T20-46
2
+ last_updated: 2026-11-13T01-55
3
3
  ---
4
4
 
5
5
  <div align="center">
@@ -27,7 +27,7 @@ Alternatively, install from Git with `pi install git:github.com/giladbarnea/pi-p
27
27
 
28
28
  ## Rich Bash layout without replacing the Bash tool
29
29
 
30
- Short commands get syntax colors in the header. Multiline commands get numbered boxes, and long commands wrap without losing their end. Result boxes show status, elapsed time and line counts. Collapsed results show ten visual tail rows; expansion shows the complete returned text.
30
+ Short commands get syntax colors in the header. Multiline commands get numbered boxes, and long commands wrap without losing their end. Result boxes show status, elapsed time and line counts. Pi's tool expansion toggle governs both boxes. Collapsed, a command box over ten rows shows its first and last five, and results show ten visual tail rows; expansion shows the complete command and returned text.
31
31
 
32
32
  The Bash palette preserves the former personal `bash-rich-highlight` choices, including function colors for built-ins. It uses `cli-highlight` with Pi theme colors, not the former HTML parser or hardcoded installation paths.
33
33
 
package/index.ts CHANGED
@@ -12,7 +12,7 @@ import { truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component } from
12
12
  import { highlight } from "cli-highlight";
13
13
 
14
14
  const JSON_HIGHLIGHT_MAX_BYTES = 200 * 1024;
15
- const OUTPUT_PREVIEW_ROWS = 10;
15
+ const PREVIEW_ROWS = 10;
16
16
  const RESET = "\x1b[0m";
17
17
 
18
18
  type BashArguments = { command?: string; timeout?: number };
@@ -96,10 +96,10 @@ function box(rows: string[], width: number, theme: Theme, caption = ""): string[
96
96
  ];
97
97
  }
98
98
 
99
- /** Keep the complete command, using a numbered box only for multiline input.
100
- * @example commandRows({command: "echo hi"}, theme, false).render(80) // A syntax-colored Bash header.
99
+ /** Draw the command, using a numbered box only for multiline input; collapsed boxes hide their middle rows.
100
+ * @example commandRows({command: "echo hi"}, theme, false, false).render(80) // A syntax-colored Bash header.
101
101
  */
102
- function commandRows(args: BashArguments, theme: Theme, pending: boolean): Component {
102
+ function commandRows(args: BashArguments, theme: Theme, pending: boolean, expanded: boolean): Component {
103
103
  const command = displayText(args.command ?? "");
104
104
  const sourceLines = command.split("\n");
105
105
  const highlighted = bashColors(command, theme).split("\n");
@@ -124,7 +124,9 @@ function commandRows(args: BashArguments, theme: Theme, pending: boolean): Compo
124
124
  const number = segmentIndex === 0 ? theme.fg("muted", String(index + 1).padStart(numberWidth)) : " ".repeat(numberWidth);
125
125
  return numberWidth ? `${number} ${segment}` : segment;
126
126
  }));
127
- return [header, ...box(rows, width, theme)];
127
+ if (expanded || rows.length <= PREVIEW_ROWS) return [header, ...box(rows, width, theme)];
128
+ const hint = wrapTextWithAnsi(`${theme.fg("muted", `… ${rows.length - PREVIEW_ROWS} more lines · `)}${keyHint("app.tools.expand", "to expand")}`, Math.max(1, width - 4));
129
+ return [header, ...box([...rows.slice(0, PREVIEW_ROWS / 2), ...hint, ...rows.slice(-PREVIEW_ROWS / 2)], width, theme)];
128
130
  });
129
131
  }
130
132
 
@@ -191,7 +193,7 @@ export default function prettyBash(pi: ExtensionAPI): void {
191
193
  active.add(state);
192
194
  }
193
195
  if (!context.isPartial) finish(state);
194
- return commandRows((args ?? {}) as BashArguments, theme, context.executionStarted && context.isPartial && state.endedAt === undefined);
196
+ return commandRows((args ?? {}) as BashArguments, theme, context.executionStarted && context.isPartial && state.endedAt === undefined, context.expanded);
195
197
  },
196
198
  renderResult(result: Result, options, theme: Theme, context: Context) {
197
199
  const output = result.content.filter(part => part.type === "text").map(part => part.text).join("\n");
@@ -214,7 +216,7 @@ export default function prettyBash(pi: ExtensionAPI): void {
214
216
  return new BashDisplay(width => {
215
217
  if (!parsed.body.trim()) return ["", `${caption}${theme.fg("dim", " · ")}${theme.fg("muted", options.isPartial ? "waiting for output" : "no output")}`];
216
218
  const innerWidth = Math.max(1, width - 4);
217
- const { skippedCount, visualLines } = truncateToVisualLines(styled, options.expanded ? Infinity : OUTPUT_PREVIEW_ROWS, innerWidth);
219
+ const { skippedCount, visualLines } = truncateToVisualLines(styled, options.expanded ? Infinity : PREVIEW_ROWS, innerWidth);
218
220
  const hint = skippedCount ? wrapTextWithAnsi(`${theme.fg("muted", `… ${skippedCount} earlier lines · `)}${keyHint("app.tools.expand", "to expand")}`, innerWidth) : [];
219
221
  const outputPath = details?.fullOutputPath ? wrapTextWithAnsi(theme.fg("muted", `Full output: ${displayText(details.fullOutputPath)}`), width) : [];
220
222
  return ["", ...box([...hint, ...visualLines], width, theme, caption), ...outputPath];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-pretty-bash",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "description": "Rich Bash command and result displays with syntax-colored commands and JSON output.",
6
6
  "keywords": [