about-system 0.0.39 → 0.0.40

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.
@@ -1,155 +1,167 @@
1
1
  #!/usr/bin/env node
2
- import p from "os";
3
- import i from "fs";
4
- import u from "path";
5
- import { fileURLToPath as x } from "url";
6
- import { g as $, a as C, b as y, C as S, S as I, c as g, D as w } from "./system-info-api-J8OqC6YU.js";
7
- const L = x(import.meta.url), d = p.platform() === "win32";
8
- function b(e, s, o) {
2
+ import g from "os";
3
+ import r from "fs";
4
+ import m from "path";
5
+ import { fileURLToPath as F } from "url";
6
+ import { g as $, a as C, b as S, C as w, S as I, c as y, D as b } from "./system-info-api-J8OqC6YU.js";
7
+ const E = F(import.meta.url), p = g.platform() === "win32";
8
+ function j(e, s, o) {
9
9
  if (!s || s.trim() === "") return "";
10
- const a = g[o.colors[e]] || g.reset, n = o.display.show_emojis && o.emojis[e] || "";
10
+ const l = y[o.colors[e]] || y.reset, i = o.display.show_emojis && o.emojis[e] || "";
11
11
  if (e === "battery" && o.display.show_emojis) {
12
- const t = s.includes("+") ? o.emojis.battery_charging : o.emojis.battery;
13
- return `${a}${t}${s}`;
12
+ const c = s.includes("+") ? o.emojis.battery_charging : o.emojis.battery;
13
+ return `${l}${c}${s}`;
14
14
  }
15
15
  if (e === "ports" && o.colors[e] === "multicolor" && s) {
16
- let c = ` ${o.display.show_emojis ? o.emojis.ports : ""}`;
17
- const r = s.split(" "), l = [31, 32, 33, 34, 35, 36];
18
- return r.forEach((f, m) => {
19
- const h = l[m % l.length];
20
- c += `\x1B[${h}m${f}\x1B[0m `;
21
- }), c.trim();
16
+ let t = ` ${o.display.show_emojis ? o.emojis.ports : ""}`;
17
+ const n = s.split(" "), a = [31, 32, 33, 34, 35, 36];
18
+ return n.forEach((f, h) => {
19
+ const u = a[h % a.length];
20
+ t += `\x1B[${u}m${f}\x1B[0m `;
21
+ }), t.trim();
22
22
  }
23
23
  if (e === "pacman" && o.colors[e] === "multicolor" && s) {
24
- const t = o.display.show_emojis ? o.emojis.pacman : "";
25
- return `${a}${t}${s}`;
24
+ const c = o.display.show_emojis ? o.emojis.pacman : "";
25
+ return `${l}${c}${s}`;
26
26
  }
27
- return `${a}${n}${s}`;
27
+ return `${l}${i}${s}`;
28
28
  }
29
- function _(e) {
30
- return e.replace(/\x1b\[[0-9;]*m/g, "");
29
+ function P(e, s) {
30
+ if (s <= 0) return e ? [e] : [];
31
+ const o = [];
32
+ let l = "", i = 0, c = "";
33
+ for (let t = 0; t < e.length; t++) {
34
+ const n = e[t];
35
+ if (n === "\x1B" && e[t + 1] === "[") {
36
+ let u = n, d = t + 1;
37
+ for (; d < e.length && e[d] !== "m"; )
38
+ u += e[d], d++;
39
+ d < e.length && (u += e[d]), l += u, c = /\x1b\[0m/.test(u) ? "" : u, t = d;
40
+ continue;
41
+ }
42
+ let a = n, f = 1;
43
+ const h = e.charCodeAt(t);
44
+ h >= 55296 && h <= 56319 && t + 1 < e.length && (a = n + e[t + 1], f = 2, t++), i >= s && (o.push(l), l = c, i = 0), l += a, i += f;
45
+ }
46
+ return l && o.push(l), o;
31
47
  }
32
- async function j(e = null) {
33
- const s = C(), o = e || s.display_order, a = await $();
48
+ async function _(e = null) {
49
+ const s = C(), o = e || s.display_order, l = await $();
34
50
  if (s.display.single_line) {
35
- const r = [];
36
- for (const l of o)
37
- for (const f of l) {
38
- const m = a[f], h = b(f, m, s);
39
- h && h.trim() && r.push(h);
51
+ const n = [];
52
+ for (const a of o)
53
+ for (const f of a) {
54
+ const h = l[f], u = j(f, h, s);
55
+ u && u.trim() && n.push(u);
40
56
  }
41
- r.length > 0 && console.log(r.join(" ") + g.reset);
57
+ n.length > 0 && console.log(n.join(" ") + y.reset);
42
58
  return;
43
59
  }
44
- const n = [];
45
- let t = "";
46
- const c = s.display.line_wrap_length;
47
- for (const r of o)
48
- for (const l of r) {
49
- const f = a[l], m = b(l, f, s);
50
- if (m && m.trim()) {
51
- const h = _(m).length, F = _(t).length;
52
- t && F + h + 1 > c ? (n.push(t), t = m) : t = t ? `${t} ${m}` : m;
53
- }
60
+ const i = s.display.line_wrap_length, c = [];
61
+ for (const n of o)
62
+ for (const a of n) {
63
+ const f = l[a], h = j(a, f, s);
64
+ h && h.trim() && c.push(h);
54
65
  }
55
- t && n.push(t), n.length > 0 ? n.forEach((r) => {
56
- console.log(r + g.reset);
66
+ const t = P(c.join(" "), i);
67
+ t.length > 0 ? t.forEach((n) => {
68
+ console.log(n + y.reset);
57
69
  }) : s.advanced.debug && console.log("No system information could be displayed");
58
70
  }
59
- function E(e) {
71
+ function O(e) {
60
72
  const s = C();
61
73
  if (e.includes("--settings-init"))
62
- return y(w) ? console.log("Settings initialized with defaults") : console.log("Failed to initialize settings"), !0;
74
+ return S(b) ? console.log("Settings initialized with defaults") : console.log("Failed to initialize settings"), !0;
63
75
  if (e.includes("--settings-show"))
64
76
  return console.log("Current settings:"), console.log(JSON.stringify(s, null, 2)), !0;
65
77
  if (e.includes("--settings-reset"))
66
- return y(w) ? console.log("Settings reset to defaults") : console.log("Failed to reset settings"), !0;
78
+ return S(b) ? console.log("Settings reset to defaults") : console.log("Failed to reset settings"), !0;
67
79
  if (e.includes("--refresh")) {
68
80
  try {
69
- i.existsSync(S) && (i.unlinkSync(S), console.log("Cache cleared"));
70
- } catch (a) {
71
- console.error("Error clearing cache:", a.message);
81
+ r.existsSync(w) && (r.unlinkSync(w), console.log("Cache cleared"));
82
+ } catch (l) {
83
+ console.error("Error clearing cache:", l.message);
72
84
  }
73
85
  return !0;
74
86
  }
75
87
  const o = e.indexOf("--set");
76
88
  if (o !== -1 && e[o + 1] && e[o + 2]) {
77
- const a = e[o + 1], n = e[o + 2];
89
+ const l = e[o + 1], i = e[o + 2];
78
90
  try {
79
- const t = n.startsWith("{") || n.startsWith("[") ? JSON.parse(n) : n, c = a.split(".");
80
- let r = s;
81
- for (let l = 0; l < c.length - 1; l++)
82
- r[c[l]] || (r[c[l]] = {}), r = r[c[l]];
83
- r[c[c.length - 1]] = t, y(s) ? console.log(`Setting ${a} = ${n}`) : console.log("Failed to save settings");
84
- } catch (t) {
85
- console.error("Error setting value:", t.message);
91
+ const c = i.startsWith("{") || i.startsWith("[") ? JSON.parse(i) : i, t = l.split(".");
92
+ let n = s;
93
+ for (let a = 0; a < t.length - 1; a++)
94
+ n[t[a]] || (n[t[a]] = {}), n = n[t[a]];
95
+ n[t[t.length - 1]] = c, S(s) ? console.log(`Setting ${l} = ${i}`) : console.log("Failed to save settings");
96
+ } catch (c) {
97
+ console.error("Error setting value:", c.message);
86
98
  }
87
99
  return !0;
88
100
  }
89
101
  return !1;
90
102
  }
91
- function P() {
92
- const e = p.homedir();
103
+ function v() {
104
+ const e = g.homedir();
93
105
  let s, o;
94
- d ? (s = u.join(e, "AppData", "Local"), o = u.join(s, "systeminfo")) : (s = u.join(e, ".config"), o = u.join(s, "systeminfo"));
95
- const a = u.resolve(L);
106
+ p ? (s = m.join(e, "AppData", "Local"), o = m.join(s, "systeminfo")) : (s = m.join(e, ".config"), o = m.join(s, "systeminfo"));
107
+ const l = m.resolve(E);
96
108
  try {
97
- if (i.existsSync(s) || i.mkdirSync(s, { recursive: !0 }), i.copyFileSync(a, o), d || i.chmodSync(o, "755"), d) {
109
+ if (r.existsSync(s) || r.mkdirSync(s, { recursive: !0 }), r.copyFileSync(l, o), p || r.chmodSync(o, "755"), p) {
98
110
  console.log("Windows installation:"), console.log("1. Script copied to:", o), console.log("2. To add to PowerShell profile, run:"), console.log(` Add-Content $PROFILE "node '${o}'"`), console.log(
99
111
  "3. To add to Command Prompt, create a batch file in your startup folder"
100
112
  );
101
- const n = u.join(s, "systeminfo-startup.bat");
102
- i.writeFileSync(n, `@echo off
113
+ const i = m.join(s, "systeminfo-startup.bat");
114
+ r.writeFileSync(i, `@echo off
103
115
  node "${o}"
104
- `), console.log("4. Batch file created:", n);
116
+ `), console.log("4. Batch file created:", i);
105
117
  } else {
106
118
  try {
107
- const f = u.join(e, ".hushlogin");
108
- i.writeFileSync(f, "");
119
+ const f = m.join(e, ".hushlogin");
120
+ r.writeFileSync(f, "");
109
121
  } catch {
110
122
  }
111
- const n = u.join(e, ".bashrc"), t = `node ${o}`;
112
- i.existsSync(n) ? i.readFileSync(n, "utf8").includes("systeminfo") || i.appendFileSync(n, `
113
- ${t}
114
- `) : i.writeFileSync(n, `${t}
123
+ const i = m.join(e, ".bashrc"), c = `node ${o}`;
124
+ r.existsSync(i) ? r.readFileSync(i, "utf8").includes("systeminfo") || r.appendFileSync(i, `
125
+ ${c}
126
+ `) : r.writeFileSync(i, `${c}
115
127
  `);
116
- const c = u.join(e, ".zshrc");
117
- i.existsSync(c) && (i.readFileSync(c, "utf8").includes("systeminfo") || i.appendFileSync(c, `
118
- ${t}
128
+ const t = m.join(e, ".zshrc");
129
+ r.existsSync(t) && (r.readFileSync(t, "utf8").includes("systeminfo") || r.appendFileSync(t, `
130
+ ${c}
119
131
  `));
120
- const r = u.join(
132
+ const n = m.join(
121
133
  e,
122
134
  ".config",
123
135
  "fish",
124
136
  "config.fish"
125
137
  );
126
- i.existsSync(r) && (i.readFileSync(r, "utf8").includes("systeminfo") || i.appendFileSync(
127
- r,
138
+ r.existsSync(n) && (r.readFileSync(n, "utf8").includes("systeminfo") || r.appendFileSync(
139
+ n,
128
140
  `
129
141
  set -U fish_greeting ""
130
- ${t}
142
+ ${c}
131
143
  `
132
144
  ));
133
- const l = u.join(
145
+ const a = m.join(
134
146
  e,
135
147
  ".config",
136
148
  "nushell",
137
149
  "config.nu"
138
150
  );
139
- i.existsSync(l) && (i.readFileSync(l, "utf8").includes("systeminfo") || i.appendFileSync(
140
- l,
151
+ r.existsSync(a) && (r.readFileSync(a, "utf8").includes("systeminfo") || r.appendFileSync(
152
+ a,
141
153
  `
142
154
  $env.config.show_banner = false
143
- ${t}
155
+ ${c}
144
156
  `
145
157
  ));
146
158
  }
147
159
  console.log("Shell greeting installation completed!");
148
- } catch (n) {
149
- console.error("Error installing shell greeting:", n.message), process.exit(1);
160
+ } catch (i) {
161
+ console.error("Error installing shell greeting:", i.message), process.exit(1);
150
162
  }
151
163
  }
152
- function O(e) {
164
+ function L(e) {
153
165
  for (const s of e)
154
166
  if (!s.startsWith("--") && s.includes(","))
155
167
  return s.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
@@ -158,7 +170,7 @@ function O(e) {
158
170
  return [s.trim()];
159
171
  return null;
160
172
  }
161
- async function v() {
173
+ async function T() {
162
174
  console.log(`
163
175
  System Info Script - TypeScript Version
164
176
 
@@ -189,9 +201,9 @@ Examples:
189
201
  about-system --json
190
202
 
191
203
  Settings file: ${I}
192
- Cache file: ${S}
204
+ Cache file: ${w}
193
205
 
194
- Platform: ${d ? "Windows" : p.platform() === "darwin" ? "macOS" : p.platform() === "linux" ? "Linux" : "Unknown"}
206
+ Platform: ${p ? "Windows" : g.platform() === "darwin" ? "macOS" : g.platform() === "linux" ? "Linux" : "Unknown"}
195
207
 
196
208
  Available display blocks:
197
209
  Basic: user, hostname, uptime, shell, os, kernel, device
@@ -202,16 +214,16 @@ Available display blocks:
202
214
  Tools: pacman, ports, containers
203
215
  `);
204
216
  }
205
- async function T() {
217
+ async function k() {
206
218
  const e = process.argv.slice(2);
207
- if (E(e))
219
+ if (O(e))
208
220
  return;
209
221
  if (e.includes("--help") || e.includes("-h")) {
210
- await v();
222
+ await T();
211
223
  return;
212
224
  }
213
225
  if (e.includes("--install")) {
214
- P();
226
+ v();
215
227
  return;
216
228
  }
217
229
  if (e.includes("--json")) {
@@ -219,18 +231,18 @@ async function T() {
219
231
  console.log(JSON.stringify(o, null, 2));
220
232
  return;
221
233
  }
222
- const s = O(e);
234
+ const s = L(e);
223
235
  if (s) {
224
- await j([s]);
236
+ await _([s]);
225
237
  return;
226
238
  }
227
- await j();
239
+ await _();
228
240
  }
229
- T().catch((e) => {
241
+ k().catch((e) => {
230
242
  console.error("Error:", e.message), process.exit(1);
231
243
  });
232
244
  export {
233
- j as displaySystemInfo,
234
- P as installShellGreeting
245
+ _ as displaySystemInfo,
246
+ v as installShellGreeting
235
247
  };
236
248
  //# sourceMappingURL=about-system-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"about-system-cli.js","sources":["../src/about-system-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport os from \"os\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getSystemInfo } from \"./system-info-api\";\nimport type { SystemInfo, SystemInfoOptions } from \"./systeminfo-types\";\n\nconst __filename = fileURLToPath(import.meta.url);\n\nimport {\n Settings,\n DEFAULT_SETTINGS,\n colors,\n SETTINGS_FILE,\n CACHE_FILE,\n loadSettings,\n saveSettings,\n} from \"./info/settings\";\n\n// Platform detection\nconst IS_WINDOWS = os.platform() === \"win32\";\n\nfunction formatValue(key: string, value: string, settings: Settings): string {\n if (!value || value.trim() === \"\") return \"\";\n\n const color =\n colors[settings.colors[key] as keyof typeof colors] || colors.reset;\n const emoji = settings.display.show_emojis ? settings.emojis[key] || \"\" : \"\";\n\n // Special handling for battery emoji\n if (key === \"battery\" && settings.display.show_emojis) {\n const batteryEmoji = value.includes(\"+\")\n ? settings.emojis.battery_charging\n : settings.emojis.battery;\n return `${color}${batteryEmoji}${value}`;\n }\n\n // Multicolor handling for ports\n if (key === \"ports\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.ports : \"\";\n let output = ` ${emoji}`;\n const ports = value.split(\" \");\n const colorCodes = [31, 32, 33, 34, 35, 36];\n ports.forEach((port, index) => {\n const colorCode = colorCodes[index % colorCodes.length];\n output += `\\x1b[${colorCode}m${port}\\x1b[0m `;\n });\n return output.trim();\n }\n\n // Multicolor handling for pacman\n if (key === \"pacman\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.pacman : \"\";\n return `${color}${emoji}${value}`;\n }\n\n return `${color}${emoji}${value}`;\n}\n\nfunction removeAnsiCodes(str: string): string {\n return str.replace(/\\x1b\\[[0-9;]*m/g, \"\");\n}\n\nasync function displaySystemInfo(\n customDisplayOrder: string[][] | null = null\n): Promise<void> {\n const settings = loadSettings();\n const displayOrder = customDisplayOrder || settings.display_order;\n\n // Get system info\n const info = await getSystemInfo();\n\n // Single line mode\n if (settings.display.single_line) {\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n if (allItems.length > 0) {\n console.log(allItems.join(\" \") + colors.reset);\n }\n return;\n }\n\n // Multi-line mode with intelligent wrapping\n const lines: string[] = [];\n let currentLine = \"\";\n const maxLineLength = settings.display.line_wrap_length;\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n\n if (formatted && formatted.trim()) {\n const formattedLength = removeAnsiCodes(formatted).length;\n const currentLineLength = removeAnsiCodes(currentLine).length;\n\n if (\n currentLine &&\n currentLineLength + formattedLength + 1 > maxLineLength\n ) {\n lines.push(currentLine);\n currentLine = formatted;\n } else {\n currentLine = currentLine ? `${currentLine} ${formatted}` : formatted;\n }\n }\n }\n }\n\n if (currentLine) {\n lines.push(currentLine);\n }\n\n // Output\n if (lines.length > 0) {\n lines.forEach((line) => {\n console.log(line + colors.reset);\n });\n } else if (settings.advanced.debug) {\n console.log(\"No system information could be displayed\");\n }\n}\n\nfunction handleSettingsCommand(args: string[]): boolean {\n const settings = loadSettings();\n\n if (args.includes(\"--settings-init\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings initialized with defaults\");\n } else {\n console.log(\"Failed to initialize settings\");\n }\n return true;\n }\n\n if (args.includes(\"--settings-show\")) {\n console.log(\"Current settings:\");\n console.log(JSON.stringify(settings, null, 2));\n return true;\n }\n\n if (args.includes(\"--settings-reset\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings reset to defaults\");\n } else {\n console.log(\"Failed to reset settings\");\n }\n return true;\n }\n\n if (args.includes(\"--refresh\")) {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n fs.unlinkSync(CACHE_FILE);\n console.log(\"Cache cleared\");\n }\n } catch (error) {\n console.error(\"Error clearing cache:\", (error as Error).message);\n }\n return true;\n }\n\n const setIndex = args.indexOf(\"--set\");\n if (setIndex !== -1 && args[setIndex + 1] && args[setIndex + 2]) {\n const key = args[setIndex + 1];\n const value = args[setIndex + 2];\n\n try {\n const parsedValue =\n value.startsWith(\"{\") || value.startsWith(\"[\")\n ? JSON.parse(value)\n : value;\n\n const keys = key.split(\".\");\n let current: any = settings;\n for (let i = 0; i < keys.length - 1; i++) {\n if (!current[keys[i]]) current[keys[i]] = {};\n current = current[keys[i]];\n }\n current[keys[keys.length - 1]] = parsedValue;\n\n if (saveSettings(settings)) {\n console.log(`Setting ${key} = ${value}`);\n } else {\n console.log(\"Failed to save settings\");\n }\n } catch (error) {\n console.error(\"Error setting value:\", (error as Error).message);\n }\n return true;\n }\n\n return false;\n}\n\nfunction installShellGreeting(): void {\n const homeDir = os.homedir();\n\n let configDir: string, scriptPath: string;\n if (IS_WINDOWS) {\n configDir = path.join(homeDir, \"AppData\", \"Local\");\n scriptPath = path.join(configDir, \"systeminfo\");\n } else {\n configDir = path.join(homeDir, \".config\");\n scriptPath = path.join(configDir, \"systeminfo\");\n }\n\n const currentScript = path.resolve(__filename);\n\n try {\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n\n fs.copyFileSync(currentScript, scriptPath);\n if (!IS_WINDOWS) {\n fs.chmodSync(scriptPath, \"755\");\n }\n\n if (IS_WINDOWS) {\n console.log(\"Windows installation:\");\n console.log(\"1. Script copied to:\", scriptPath);\n console.log(\"2. To add to PowerShell profile, run:\");\n console.log(` Add-Content $PROFILE \"node '${scriptPath}'\"`);\n console.log(\n \"3. To add to Command Prompt, create a batch file in your startup folder\"\n );\n\n const startupBat = path.join(configDir, \"systeminfo-startup.bat\");\n fs.writeFileSync(startupBat, `@echo off\\nnode \"${scriptPath}\"\\n`);\n console.log(\"4. Batch file created:\", startupBat);\n } else {\n try {\n const hushLoginPath = path.join(homeDir, \".hushlogin\");\n fs.writeFileSync(hushLoginPath, \"\");\n } catch {}\n\n const bashrcPath = path.join(homeDir, \".bashrc\");\n const bashLine = `node ${scriptPath}`;\n\n if (fs.existsSync(bashrcPath)) {\n const bashrc = fs.readFileSync(bashrcPath, \"utf8\");\n if (!bashrc.includes(\"systeminfo\")) {\n fs.appendFileSync(bashrcPath, `\\n${bashLine}\\n`);\n }\n } else {\n fs.writeFileSync(bashrcPath, `${bashLine}\\n`);\n }\n\n const zshrcPath = path.join(homeDir, \".zshrc\");\n if (fs.existsSync(zshrcPath)) {\n const zshrc = fs.readFileSync(zshrcPath, \"utf8\");\n if (!zshrc.includes(\"systeminfo\")) {\n fs.appendFileSync(zshrcPath, `\\n${bashLine}\\n`);\n }\n }\n\n const fishConfigPath = path.join(\n homeDir,\n \".config\",\n \"fish\",\n \"config.fish\"\n );\n if (fs.existsSync(fishConfigPath)) {\n const fishConfig = fs.readFileSync(fishConfigPath, \"utf8\");\n if (!fishConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n fishConfigPath,\n `\\nset -U fish_greeting \"\"\\n${bashLine}\\n`\n );\n }\n }\n\n const nushellConfigPath = path.join(\n homeDir,\n \".config\",\n \"nushell\",\n \"config.nu\"\n );\n if (fs.existsSync(nushellConfigPath)) {\n const nushellConfig = fs.readFileSync(nushellConfigPath, \"utf8\");\n if (!nushellConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n nushellConfigPath,\n `\\n$env.config.show_banner = false\\n${bashLine}\\n`\n );\n }\n }\n }\n\n console.log(\"Shell greeting installation completed!\");\n } catch (error) {\n console.error(\"Error installing shell greeting:\", (error as Error).message);\n process.exit(1);\n }\n}\n\nfunction parseCLIMode(args: string[]): string[] | null {\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && arg.includes(\",\")) {\n return arg\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n }\n }\n\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && !arg.includes(\"=\") && arg.length > 0) {\n return [arg.trim()];\n }\n }\n\n return null;\n}\n\nasync function showHelp(): Promise<void> {\n console.log(`\nSystem Info Script - TypeScript Version\n\nUsage:\n about-system [options]\n about-system <part1,part2,...> # CLI mode: show specific parts only\n\nOptions:\n --help, -h Show this help message\n --install Install as shell greeting\n --settings-init Initialize settings file with defaults\n --settings-show Display current settings\n --settings-reset Reset settings to defaults\n --refresh Clear the cache file\n --set <key> <value> Set a configuration value (use dot notation)\n --json Output as JSON\n\nExamples:\n about-system # Show all info (default)\n about-system cpu,os # Show only CPU and OS info\n about-system user,hostname,ip # Show user, hostname, and IP\n about-system disk_used # Show only disk usage\n about-system --install\n about-system --set display.show_emojis false\n about-system --set colors.user blue\n about-system --set emojis.cpu \"🚀 \"\n about-system --set labels.cpu \"Processor\"\n about-system --json\n\nSettings file: ${SETTINGS_FILE}\nCache file: ${CACHE_FILE}\n\nPlatform: ${\n IS_WINDOWS\n ? \"Windows\"\n : os.platform() === \"darwin\"\n ? \"macOS\"\n : os.platform() === \"linux\"\n ? \"Linux\"\n : \"Unknown\"\n }\n\nAvailable display blocks:\n Basic: user, hostname, uptime, shell, os, kernel, device\n Resources: disk_used, ram_used, memory_available, swap_used, top_process\n Network: ip, iplocal, city, domain, isp, network_interfaces\n Hardware: cpu, gpu, temperature, battery, screen_resolution\n System: load_average, users_logged_in, mount_points, services_running\n Tools: pacman, ports, containers\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n\n if (handleSettingsCommand(args)) {\n return;\n }\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n await showHelp();\n return;\n }\n\n if (args.includes(\"--install\")) {\n installShellGreeting();\n return;\n }\n\n if (args.includes(\"--json\")) {\n const info = await getSystemInfo();\n console.log(JSON.stringify(info, null, 2));\n return;\n }\n\n const cliParts = parseCLIMode(args);\n if (cliParts) {\n const customDisplayOrder = [cliParts];\n await displaySystemInfo(customDisplayOrder);\n return;\n }\n\n await displaySystemInfo();\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error.message);\n process.exit(1);\n});\n\nexport { displaySystemInfo, installShellGreeting };\n"],"names":["__filename","fileURLToPath","IS_WINDOWS","os","formatValue","key","value","settings","color","colors","emoji","batteryEmoji","output","ports","colorCodes","port","index","colorCode","removeAnsiCodes","str","displaySystemInfo","customDisplayOrder","loadSettings","displayOrder","info","getSystemInfo","allItems","group","formatted","lines","currentLine","maxLineLength","formattedLength","currentLineLength","line","handleSettingsCommand","args","saveSettings","DEFAULT_SETTINGS","fs","CACHE_FILE","error","setIndex","parsedValue","keys","current","i","installShellGreeting","homeDir","configDir","scriptPath","path","currentScript","startupBat","hushLoginPath","bashrcPath","bashLine","zshrcPath","fishConfigPath","nushellConfigPath","parseCLIMode","arg","part","showHelp","SETTINGS_FILE","main","cliParts"],"mappings":";;;;;;AAQA,MAAMA,IAAaC,EAAc,YAAY,GAAG,GAa1CC,IAAaC,EAAG,SAAA,MAAe;AAErC,SAASC,EAAYC,GAAaC,GAAeC,GAA4B;AAC3E,MAAI,CAACD,KAASA,EAAM,KAAA,MAAW,GAAI,QAAO;AAE1C,QAAME,IACJC,EAAOF,EAAS,OAAOF,CAAG,CAAwB,KAAKI,EAAO,OAC1DC,IAAQH,EAAS,QAAQ,eAAcA,EAAS,OAAOF,CAAG,KAAK;AAGrE,MAAIA,MAAQ,aAAaE,EAAS,QAAQ,aAAa;AACrD,UAAMI,IAAeL,EAAM,SAAS,GAAG,IACnCC,EAAS,OAAO,mBAChBA,EAAS,OAAO;AACpB,WAAO,GAAGC,CAAK,GAAGG,CAAY,GAAGL,CAAK;AAAA,EACxC;AAGA,MAAID,MAAQ,WAAWE,EAAS,OAAOF,CAAG,MAAM,gBAAgBC,GAAO;AAErE,Q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ClB,UACA,SACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CASD;AACD;AAEA,eAAe8D,IAAsB;AACnC,QAAM7B,IAAO,QAAQ,KAAK,MAAM,CAAC;AAEjC,MAAID,EAAsBC,CAAI;AAC5B;AAGF,MAAIA,EAAK,SAAS,QAAQ,KAAKA,EAAK,SAAS,IAAI,GAAG;AAClD,UAAM2B,EAAA;AACN;AAAA,EACF;AAEA,MAAI3B,EAAK,SAAS,WAAW,GAAG;AAC9B,IAAAW,EAAA;AACA;AAAA,EACF;AAEA,MAAIX,EAAK,SAAS,QAAQ,GAAG;AAC3B,UAAMZ,IAAO,MAAMC,EAAA;AACnB,YAAQ,IAAI,KAAK,UAAUD,GAAM,MAAM,CAAC,CAAC;AACzC;AAAA,EACF;AAEA,QAAM0C,IAAWN,EAAaxB,CAAI;AAClC,MAAI8B,GAAU;AAEZ,UAAM9C,EADqB,CAAC8C,CAAQ,CACM;AAC1C;AAAA,EACF;AAEA,QAAM9C,EAAA;AACR;AAEA6C,IAAO,MAAM,CAACxB,MAAU;AACtB,UAAQ,MAAM,UAAUA,EAAM,OAAO,GACrC,QAAQ,KAAK,CAAC;AAChB,CAAC;"}
1
+ {"version":3,"file":"about-system-cli.js","sources":["../src/about-system-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport os from \"os\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getSystemInfo } from \"./system-info-api\";\nimport type { SystemInfo, SystemInfoOptions } from \"./systeminfo-types\";\n\nconst __filename = fileURLToPath(import.meta.url);\n\nimport {\n Settings,\n DEFAULT_SETTINGS,\n colors,\n SETTINGS_FILE,\n CACHE_FILE,\n loadSettings,\n saveSettings,\n} from \"./info/settings\";\n\n// Platform detection\nconst IS_WINDOWS = os.platform() === \"win32\";\n\nfunction formatValue(key: string, value: string, settings: Settings): string {\n if (!value || value.trim() === \"\") return \"\";\n\n const color =\n colors[settings.colors[key] as keyof typeof colors] || colors.reset;\n const emoji = settings.display.show_emojis ? settings.emojis[key] || \"\" : \"\";\n\n // Special handling for battery emoji\n if (key === \"battery\" && settings.display.show_emojis) {\n const batteryEmoji = value.includes(\"+\")\n ? settings.emojis.battery_charging\n : settings.emojis.battery;\n return `${color}${batteryEmoji}${value}`;\n }\n\n // Multicolor handling for ports\n if (key === \"ports\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.ports : \"\";\n let output = ` ${emoji}`;\n const ports = value.split(\" \");\n const colorCodes = [31, 32, 33, 34, 35, 36];\n ports.forEach((port, index) => {\n const colorCode = colorCodes[index % colorCodes.length];\n output += `\\x1b[${colorCode}m${port}\\x1b[0m `;\n });\n return output.trim();\n }\n\n // Multicolor handling for pacman\n if (key === \"pacman\" && settings.colors[key] === \"multicolor\" && value) {\n const emoji = settings.display.show_emojis ? settings.emojis.pacman : \"\";\n return `${color}${emoji}${value}`;\n }\n\n return `${color}${emoji}${value}`;\n}\n\n/**\n * Wraps text to a maximum visible width, filling each line completely with\n * characters before moving on. Unlike block-boundary wrapping, this breaks in\n * the middle of an info block when it doesn't fit, so no visible space is left\n * unused at the end of a line.\n *\n * ANSI color codes are copied verbatim and never counted toward the width, and\n * the active color is re-applied at the start of each wrapped line so colors\n * survive a mid-block break. Emoji surrogate pairs are kept intact.\n *\n * @param text - The text to wrap (may contain ANSI escape sequences)\n * @param maxLength - Maximum visible characters per line\n * @returns Array of wrapped lines\n */\nfunction wrapAnsiText(text: string, maxLength: number): string[] {\n if (maxLength <= 0) return text ? [text] : [];\n\n const lines: string[] = [];\n let currentLine = \"\";\n let visibleCount = 0;\n let activeAnsi = \"\";\n\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n\n // Copy ANSI escape sequences verbatim without counting them.\n if (char === \"\\x1b\" && text[i + 1] === \"[\") {\n let seq = char;\n let j = i + 1;\n while (j < text.length && text[j] !== \"m\") {\n seq += text[j];\n j++;\n }\n if (j < text.length) seq += text[j]; // include the trailing \"m\"\n currentLine += seq;\n // Track the active color so wrapped lines keep it; a reset clears it.\n activeAnsi = /\\x1b\\[0m/.test(seq) ? \"\" : seq;\n i = j;\n continue;\n }\n\n // Keep an emoji (surrogate pair) together and count it as width 2.\n let unit = char;\n let width = 1;\n const code = text.charCodeAt(i);\n if (code >= 0xd800 && code <= 0xdbff && i + 1 < text.length) {\n unit = char + text[i + 1];\n width = 2;\n i++;\n }\n\n // Line is full: break here, even in the middle of an info block.\n if (visibleCount >= maxLength) {\n lines.push(currentLine);\n currentLine = activeAnsi;\n visibleCount = 0;\n }\n\n currentLine += unit;\n visibleCount += width;\n }\n\n if (currentLine) lines.push(currentLine);\n\n return lines;\n}\n\nasync function displaySystemInfo(\n customDisplayOrder: string[][] | null = null\n): Promise<void> {\n const settings = loadSettings();\n const displayOrder = customDisplayOrder || settings.display_order;\n\n // Get system info\n const info = await getSystemInfo();\n\n // Single line mode\n if (settings.display.single_line) {\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n if (allItems.length > 0) {\n console.log(allItems.join(\" \") + colors.reset);\n }\n return;\n }\n\n // Multi-line mode: fill each line completely with characters, wrapping in\n // the middle of an info block when it no longer fits.\n const maxLineLength = settings.display.line_wrap_length;\n const allItems: string[] = [];\n\n for (const group of displayOrder) {\n for (const key of group) {\n const value = info[key as keyof SystemInfo] as string;\n const formatted = formatValue(key, value, settings);\n\n if (formatted && formatted.trim()) {\n allItems.push(formatted);\n }\n }\n }\n\n const lines = wrapAnsiText(allItems.join(\" \"), maxLineLength);\n\n // Output\n if (lines.length > 0) {\n lines.forEach((line) => {\n console.log(line + colors.reset);\n });\n } else if (settings.advanced.debug) {\n console.log(\"No system information could be displayed\");\n }\n}\n\nfunction handleSettingsCommand(args: string[]): boolean {\n const settings = loadSettings();\n\n if (args.includes(\"--settings-init\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings initialized with defaults\");\n } else {\n console.log(\"Failed to initialize settings\");\n }\n return true;\n }\n\n if (args.includes(\"--settings-show\")) {\n console.log(\"Current settings:\");\n console.log(JSON.stringify(settings, null, 2));\n return true;\n }\n\n if (args.includes(\"--settings-reset\")) {\n if (saveSettings(DEFAULT_SETTINGS)) {\n console.log(\"Settings reset to defaults\");\n } else {\n console.log(\"Failed to reset settings\");\n }\n return true;\n }\n\n if (args.includes(\"--refresh\")) {\n try {\n if (fs.existsSync(CACHE_FILE)) {\n fs.unlinkSync(CACHE_FILE);\n console.log(\"Cache cleared\");\n }\n } catch (error) {\n console.error(\"Error clearing cache:\", (error as Error).message);\n }\n return true;\n }\n\n const setIndex = args.indexOf(\"--set\");\n if (setIndex !== -1 && args[setIndex + 1] && args[setIndex + 2]) {\n const key = args[setIndex + 1];\n const value = args[setIndex + 2];\n\n try {\n const parsedValue =\n value.startsWith(\"{\") || value.startsWith(\"[\")\n ? JSON.parse(value)\n : value;\n\n const keys = key.split(\".\");\n let current: any = settings;\n for (let i = 0; i < keys.length - 1; i++) {\n if (!current[keys[i]]) current[keys[i]] = {};\n current = current[keys[i]];\n }\n current[keys[keys.length - 1]] = parsedValue;\n\n if (saveSettings(settings)) {\n console.log(`Setting ${key} = ${value}`);\n } else {\n console.log(\"Failed to save settings\");\n }\n } catch (error) {\n console.error(\"Error setting value:\", (error as Error).message);\n }\n return true;\n }\n\n return false;\n}\n\nfunction installShellGreeting(): void {\n const homeDir = os.homedir();\n\n let configDir: string, scriptPath: string;\n if (IS_WINDOWS) {\n configDir = path.join(homeDir, \"AppData\", \"Local\");\n scriptPath = path.join(configDir, \"systeminfo\");\n } else {\n configDir = path.join(homeDir, \".config\");\n scriptPath = path.join(configDir, \"systeminfo\");\n }\n\n const currentScript = path.resolve(__filename);\n\n try {\n if (!fs.existsSync(configDir)) {\n fs.mkdirSync(configDir, { recursive: true });\n }\n\n fs.copyFileSync(currentScript, scriptPath);\n if (!IS_WINDOWS) {\n fs.chmodSync(scriptPath, \"755\");\n }\n\n if (IS_WINDOWS) {\n console.log(\"Windows installation:\");\n console.log(\"1. Script copied to:\", scriptPath);\n console.log(\"2. To add to PowerShell profile, run:\");\n console.log(` Add-Content $PROFILE \"node '${scriptPath}'\"`);\n console.log(\n \"3. To add to Command Prompt, create a batch file in your startup folder\"\n );\n\n const startupBat = path.join(configDir, \"systeminfo-startup.bat\");\n fs.writeFileSync(startupBat, `@echo off\\nnode \"${scriptPath}\"\\n`);\n console.log(\"4. Batch file created:\", startupBat);\n } else {\n try {\n const hushLoginPath = path.join(homeDir, \".hushlogin\");\n fs.writeFileSync(hushLoginPath, \"\");\n } catch {}\n\n const bashrcPath = path.join(homeDir, \".bashrc\");\n const bashLine = `node ${scriptPath}`;\n\n if (fs.existsSync(bashrcPath)) {\n const bashrc = fs.readFileSync(bashrcPath, \"utf8\");\n if (!bashrc.includes(\"systeminfo\")) {\n fs.appendFileSync(bashrcPath, `\\n${bashLine}\\n`);\n }\n } else {\n fs.writeFileSync(bashrcPath, `${bashLine}\\n`);\n }\n\n const zshrcPath = path.join(homeDir, \".zshrc\");\n if (fs.existsSync(zshrcPath)) {\n const zshrc = fs.readFileSync(zshrcPath, \"utf8\");\n if (!zshrc.includes(\"systeminfo\")) {\n fs.appendFileSync(zshrcPath, `\\n${bashLine}\\n`);\n }\n }\n\n const fishConfigPath = path.join(\n homeDir,\n \".config\",\n \"fish\",\n \"config.fish\"\n );\n if (fs.existsSync(fishConfigPath)) {\n const fishConfig = fs.readFileSync(fishConfigPath, \"utf8\");\n if (!fishConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n fishConfigPath,\n `\\nset -U fish_greeting \"\"\\n${bashLine}\\n`\n );\n }\n }\n\n const nushellConfigPath = path.join(\n homeDir,\n \".config\",\n \"nushell\",\n \"config.nu\"\n );\n if (fs.existsSync(nushellConfigPath)) {\n const nushellConfig = fs.readFileSync(nushellConfigPath, \"utf8\");\n if (!nushellConfig.includes(\"systeminfo\")) {\n fs.appendFileSync(\n nushellConfigPath,\n `\\n$env.config.show_banner = false\\n${bashLine}\\n`\n );\n }\n }\n }\n\n console.log(\"Shell greeting installation completed!\");\n } catch (error) {\n console.error(\"Error installing shell greeting:\", (error as Error).message);\n process.exit(1);\n }\n}\n\nfunction parseCLIMode(args: string[]): string[] | null {\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && arg.includes(\",\")) {\n return arg\n .split(\",\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n }\n }\n\n for (const arg of args) {\n if (!arg.startsWith(\"--\") && !arg.includes(\"=\") && arg.length > 0) {\n return [arg.trim()];\n }\n }\n\n return null;\n}\n\nasync function showHelp(): Promise<void> {\n console.log(`\nSystem Info Script - TypeScript Version\n\nUsage:\n about-system [options]\n about-system <part1,part2,...> # CLI mode: show specific parts only\n\nOptions:\n --help, -h Show this help message\n --install Install as shell greeting\n --settings-init Initialize settings file with defaults\n --settings-show Display current settings\n --settings-reset Reset settings to defaults\n --refresh Clear the cache file\n --set <key> <value> Set a configuration value (use dot notation)\n --json Output as JSON\n\nExamples:\n about-system # Show all info (default)\n about-system cpu,os # Show only CPU and OS info\n about-system user,hostname,ip # Show user, hostname, and IP\n about-system disk_used # Show only disk usage\n about-system --install\n about-system --set display.show_emojis false\n about-system --set colors.user blue\n about-system --set emojis.cpu \"🚀 \"\n about-system --set labels.cpu \"Processor\"\n about-system --json\n\nSettings file: ${SETTINGS_FILE}\nCache file: ${CACHE_FILE}\n\nPlatform: ${\n IS_WINDOWS\n ? \"Windows\"\n : os.platform() === \"darwin\"\n ? \"macOS\"\n : os.platform() === \"linux\"\n ? \"Linux\"\n : \"Unknown\"\n }\n\nAvailable display blocks:\n Basic: user, hostname, uptime, shell, os, kernel, device\n Resources: disk_used, ram_used, memory_available, swap_used, top_process\n Network: ip, iplocal, city, domain, isp, network_interfaces\n Hardware: cpu, gpu, temperature, battery, screen_resolution\n System: load_average, users_logged_in, mount_points, services_running\n Tools: pacman, ports, containers\n`);\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n\n if (handleSettingsCommand(args)) {\n return;\n }\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n await showHelp();\n return;\n }\n\n if (args.includes(\"--install\")) {\n installShellGreeting();\n return;\n }\n\n if (args.includes(\"--json\")) {\n const info = await getSystemInfo();\n console.log(JSON.stringify(info, null, 2));\n return;\n }\n\n const cliParts = parseCLIMode(args);\n if (cliParts) {\n const customDisplayOrder = [cliParts];\n await displaySystemInfo(customDisplayOrder);\n return;\n }\n\n await displaySystemInfo();\n}\n\nmain().catch((error) => {\n console.error(\"Error:\", error.message);\n process.exit(1);\n});\n\nexport { displaySystemInfo, installShellGreeting };\n"],"names":["__filename","fileURLToPath","IS_WINDOWS","os","formatValue","key","value","settings","color","colors","emoji","batteryEmoji","output","ports","colorCodes","port","index","colorCode","wrapAnsiText","text","maxLength","lines","currentLine","visibleCount","activeAnsi","i","char","seq","j","unit","width","code","displaySystemInfo","customDisplayOrder","loadSettings","displayOrder","info","getSystemInfo","allItems","group","formatted","maxLineLength","line","handleSettingsCommand","args","saveSettings","DEFAULT_SETTINGS","fs","CACHE_FILE","error","setIndex","parsedValue","keys","current","installShellGreeting","homeDir","configDir","scriptPath","path","currentScript","startupBat","hushLoginPath","bashrcPath","bashLine","zshrcPath","fishConfigPath","nushellConfigPath","parseCLIMode","arg","part","showHelp","SETTINGS_FILE","main","cliParts"],"mappings":";;;;;;AAQA,MAAMA,IAAaC,EAAc,YAAY,GAAG,GAa1CC,IAAaC,EAAG,SAAA,MAAe;AAErC,SAASC,EAAYC,GAAaC,GAAeC,GAA4B;AAC3E,MAAI,CAACD,KAASA,EAAM,KAAA,MAAW,GAAI,QAAO;AAE1C,QAAME,IACJC,EAAOF,EAAS,OAAOF,CAAG,CAAwB,KAAKI,EAAO,OAC1DC,IAAQH,EAAS,QAAQ,eAAcA,EAAS,OAAOF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AACN;AAAA,EACF;AAEA,MAAI1B,EAAK,SAAS,WAAW,GAAG;AAC9B,IAAAU,EAAA;AACA;AAAA,EACF;AAEA,MAAIV,EAAK,SAAS,QAAQ,GAAG;AAC3B,UAAMR,IAAO,MAAMC,EAAA;AACnB,YAAQ,IAAI,KAAK,UAAUD,GAAM,MAAM,CAAC,CAAC;AACzC;AAAA,EACF;AAEA,QAAMqC,IAAWN,EAAavB,CAAI;AAClC,MAAI6B,GAAU;AAEZ,UAAMzC,EADqB,CAACyC,CAAQ,CACM;AAC1C;AAAA,EACF;AAEA,QAAMzC,EAAA;AACR;AAEAwC,IAAO,MAAM,CAACvB,MAAU;AACtB,UAAQ,MAAM,UAAUA,EAAM,OAAO,GACrC,QAAQ,KAAK,CAAC;AAChB,CAAC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "about-system",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "A Node.js script to display key system information with emojis. Cross-platform support for Windows, macOS, and Linux with customizable output and caching.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -58,8 +58,71 @@ function formatValue(key: string, value: string, settings: Settings): string {
58
58
  return `${color}${emoji}${value}`;
59
59
  }
60
60
 
61
- function removeAnsiCodes(str: string): string {
62
- return str.replace(/\x1b\[[0-9;]*m/g, "");
61
+ /**
62
+ * Wraps text to a maximum visible width, filling each line completely with
63
+ * characters before moving on. Unlike block-boundary wrapping, this breaks in
64
+ * the middle of an info block when it doesn't fit, so no visible space is left
65
+ * unused at the end of a line.
66
+ *
67
+ * ANSI color codes are copied verbatim and never counted toward the width, and
68
+ * the active color is re-applied at the start of each wrapped line so colors
69
+ * survive a mid-block break. Emoji surrogate pairs are kept intact.
70
+ *
71
+ * @param text - The text to wrap (may contain ANSI escape sequences)
72
+ * @param maxLength - Maximum visible characters per line
73
+ * @returns Array of wrapped lines
74
+ */
75
+ function wrapAnsiText(text: string, maxLength: number): string[] {
76
+ if (maxLength <= 0) return text ? [text] : [];
77
+
78
+ const lines: string[] = [];
79
+ let currentLine = "";
80
+ let visibleCount = 0;
81
+ let activeAnsi = "";
82
+
83
+ for (let i = 0; i < text.length; i++) {
84
+ const char = text[i];
85
+
86
+ // Copy ANSI escape sequences verbatim without counting them.
87
+ if (char === "\x1b" && text[i + 1] === "[") {
88
+ let seq = char;
89
+ let j = i + 1;
90
+ while (j < text.length && text[j] !== "m") {
91
+ seq += text[j];
92
+ j++;
93
+ }
94
+ if (j < text.length) seq += text[j]; // include the trailing "m"
95
+ currentLine += seq;
96
+ // Track the active color so wrapped lines keep it; a reset clears it.
97
+ activeAnsi = /\x1b\[0m/.test(seq) ? "" : seq;
98
+ i = j;
99
+ continue;
100
+ }
101
+
102
+ // Keep an emoji (surrogate pair) together and count it as width 2.
103
+ let unit = char;
104
+ let width = 1;
105
+ const code = text.charCodeAt(i);
106
+ if (code >= 0xd800 && code <= 0xdbff && i + 1 < text.length) {
107
+ unit = char + text[i + 1];
108
+ width = 2;
109
+ i++;
110
+ }
111
+
112
+ // Line is full: break here, even in the middle of an info block.
113
+ if (visibleCount >= maxLength) {
114
+ lines.push(currentLine);
115
+ currentLine = activeAnsi;
116
+ visibleCount = 0;
117
+ }
118
+
119
+ currentLine += unit;
120
+ visibleCount += width;
121
+ }
122
+
123
+ if (currentLine) lines.push(currentLine);
124
+
125
+ return lines;
63
126
  }
64
127
 
65
128
  async function displaySystemInfo(
@@ -91,10 +154,10 @@ async function displaySystemInfo(
91
154
  return;
92
155
  }
93
156
 
94
- // Multi-line mode with intelligent wrapping
95
- const lines: string[] = [];
96
- let currentLine = "";
157
+ // Multi-line mode: fill each line completely with characters, wrapping in
158
+ // the middle of an info block when it no longer fits.
97
159
  const maxLineLength = settings.display.line_wrap_length;
160
+ const allItems: string[] = [];
98
161
 
99
162
  for (const group of displayOrder) {
100
163
  for (const key of group) {
@@ -102,25 +165,12 @@ async function displaySystemInfo(
102
165
  const formatted = formatValue(key, value, settings);
103
166
 
104
167
  if (formatted && formatted.trim()) {
105
- const formattedLength = removeAnsiCodes(formatted).length;
106
- const currentLineLength = removeAnsiCodes(currentLine).length;
107
-
108
- if (
109
- currentLine &&
110
- currentLineLength + formattedLength + 1 > maxLineLength
111
- ) {
112
- lines.push(currentLine);
113
- currentLine = formatted;
114
- } else {
115
- currentLine = currentLine ? `${currentLine} ${formatted}` : formatted;
116
- }
168
+ allItems.push(formatted);
117
169
  }
118
170
  }
119
171
  }
120
172
 
121
- if (currentLine) {
122
- lines.push(currentLine);
123
- }
173
+ const lines = wrapAnsiText(allItems.join(" "), maxLineLength);
124
174
 
125
175
  // Output
126
176
  if (lines.length > 0) {