synth-shell-theme 1.3.9__py3-none-any.whl

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 (82) hide show
  1. synth_shell_theme/__init__.py +7 -0
  2. synth_shell_theme/__main__.py +8 -0
  3. synth_shell_theme/assets/studio.html +1920 -0
  4. synth_shell_theme/cli.py +887 -0
  5. synth_shell_theme/core.py +1695 -0
  6. synth_shell_theme/ecosystem.py +537 -0
  7. synth_shell_theme/patches.py +1853 -0
  8. synth_shell_theme/paths.py +363 -0
  9. synth_shell_theme/separators.py +320 -0
  10. synth_shell_theme/server.py +506 -0
  11. synth_shell_theme/themes/01-screenshot-match.conf +30 -0
  12. synth_shell_theme/themes/02-current-live-theme.conf +30 -0
  13. synth_shell_theme/themes/03-dracula-punch.conf +30 -0
  14. synth_shell_theme/themes/04-nord-ice.conf +30 -0
  15. synth_shell_theme/themes/05-matrix-green.conf +30 -0
  16. synth_shell_theme/themes/06-amber-heat.conf +30 -0
  17. synth_shell_theme/themes/07-cloud-ops.conf +30 -0
  18. synth_shell_theme/themes/08-catppuccin-mauve.conf +30 -0
  19. synth_shell_theme/themes/09-solarized-night.conf +30 -0
  20. synth_shell_theme/themes/10-gruvbox-dark.conf +30 -0
  21. synth_shell_theme/themes/11-monokai-neon.conf +30 -0
  22. synth_shell_theme/themes/12-tokyo-night.conf +30 -0
  23. synth_shell_theme/themes/13-synthwave-pink.conf +30 -0
  24. synth_shell_theme/themes/14-forest-mint.conf +30 -0
  25. synth_shell_theme/themes/15-ruby-steel.conf +30 -0
  26. synth_shell_theme/themes/16-ice-gold.conf +30 -0
  27. synth_shell_theme/themes/17-aqua-slate.conf +30 -0
  28. synth_shell_theme/themes/18-cyber-lime.conf +30 -0
  29. synth_shell_theme/themes/19-lavender-sunset.conf +30 -0
  30. synth_shell_theme/themes/20-minimal-mono.conf +30 -0
  31. synth_shell_theme/themes/21-rose-pine.conf +30 -0
  32. synth_shell_theme/themes/22-kanagawa.conf +30 -0
  33. synth_shell_theme/themes/23-everforest.conf +30 -0
  34. synth_shell_theme/themes/24-one-dark.conf +30 -0
  35. synth_shell_theme/themes/25-ayu-dark.conf +30 -0
  36. synth_shell_theme/themes/26-nightfox.conf +30 -0
  37. synth_shell_theme/themes/27-palenight.conf +30 -0
  38. synth_shell_theme/themes/28-cyberdream.conf +30 -0
  39. synth_shell_theme/themes/29-moonlight.conf +30 -0
  40. synth_shell_theme/themes/30-poimandres.conf +30 -0
  41. synth_shell_theme/themes/31-tokyo-storm.conf +30 -0
  42. synth_shell_theme/themes/32-catppuccin-mocha.conf +30 -0
  43. synth_shell_theme/themes/33-nordic-aurora.conf +30 -0
  44. synth_shell_theme/themes/34-horizon-synth.conf +30 -0
  45. synth_shell_theme/themes/35-gruvbox-material.conf +30 -0
  46. synth_shell_theme/themes/36-oxocarbon.conf +30 -0
  47. synth_shell_theme/themes/37-catppuccin-latte.conf +30 -0
  48. synth_shell_theme/themes/38-tokyo-twilight.conf +30 -0
  49. synth_shell_theme/themes/39-solarized-ocean.conf +30 -0
  50. synth_shell_theme/themes/40-vaporwave-sunset.conf +30 -0
  51. synth_shell_theme/themes/41-deep-abyss.conf +30 -0
  52. synth_shell_theme/themes/42-sakura-blossom.conf +30 -0
  53. synth_shell_theme/themes/43-emerald-forest.conf +30 -0
  54. synth_shell_theme/themes/44-vesper.conf +30 -0
  55. synth_shell_theme/themes/45-cobalt-neon.conf +30 -0
  56. synth_shell_theme/themes/46-desert-dunes.conf +30 -0
  57. synth_shell_theme/themes/47-cyber-samurai.conf +30 -0
  58. synth_shell_theme/themes/48-glacier-mint.conf +30 -0
  59. synth_shell_theme/themes/49-carbon-titanium.conf +30 -0
  60. synth_shell_theme/themes/50-matcha-latte.conf +30 -0
  61. synth_shell_theme/themes/51-volcanic-magma.conf +30 -0
  62. synth_shell_theme/themes/52-catppuccin-frappe.conf +30 -0
  63. synth_shell_theme/themes/53-bioluminescence.conf +30 -0
  64. synth_shell_theme/themes/54-mocha-caramel.conf +30 -0
  65. synth_shell_theme/themes/55-neon-genesis.conf +30 -0
  66. synth_shell_theme/themes/56-midnight-amethyst.conf +30 -0
  67. synth_shell_theme/themes/57-andromeda.conf +30 -0
  68. synth_shell_theme/themes/58-golden-velvet.conf +30 -0
  69. synth_shell_theme/themes/59-miami-vice.conf +30 -0
  70. synth_shell_theme/themes/60-zen-garden.conf +30 -0
  71. synth_shell_theme/themes/61-google-cloud.conf +30 -0
  72. synth_shell_theme/themes/62-github-dark.conf +30 -0
  73. synth_shell_theme/themes/63-cyberpunk-edgerunners.conf +30 -0
  74. synth_shell_theme/themes/64-vscode-dark.conf +30 -0
  75. synth_shell_theme/themes.py +580 -0
  76. synth_shell_theme/tui.py +632 -0
  77. synth_shell_theme-1.3.9.dist-info/METADATA +261 -0
  78. synth_shell_theme-1.3.9.dist-info/RECORD +82 -0
  79. synth_shell_theme-1.3.9.dist-info/WHEEL +5 -0
  80. synth_shell_theme-1.3.9.dist-info/entry_points.txt +3 -0
  81. synth_shell_theme-1.3.9.dist-info/licenses/LICENSE +21 -0
  82. synth_shell_theme-1.3.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,887 @@
1
+ """Command-line interface for `synth-shell-theme` and `synth-shell-separator` (v1.1.0)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import random
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ from synth_shell_theme import __version__
12
+ from synth_shell_theme.core import (
13
+ VALID_FONT_EFFECTS,
14
+ apply_ascii_safe_mode,
15
+ apply_auto_system_theme,
16
+ apply_layout_options,
17
+ apply_separators,
18
+ apply_theme,
19
+ backup_config,
20
+ benchmark_prompt,
21
+ detect_current_separators,
22
+ detect_current_theme,
23
+ doctor_fix,
24
+ export_preset,
25
+ export_static_studio,
26
+ generate_bash_completion,
27
+ import_preset,
28
+ list_backups,
29
+ read_current_state,
30
+ read_greeter_state,
31
+ restore_backup,
32
+ sync_greeter_theme,
33
+ sync_root_config,
34
+ toggle_light_dark_theme,
35
+ )
36
+ from synth_shell_theme.ecosystem import (
37
+ export_starship_toml,
38
+ import_external_theme,
39
+ ssh_install_remote,
40
+ sync_ecosystem,
41
+ )
42
+ from synth_shell_theme.patches import (
43
+ apply_runtime_patches,
44
+ inspect_patches,
45
+ install_upstream_synth_shell,
46
+ )
47
+ from synth_shell_theme.paths import get_prompt_script_path, setup_console, system_summary
48
+ from synth_shell_theme.separators import ALL_PRESETS, resolve_separator_input
49
+ from synth_shell_theme.themes import (
50
+ BOLD,
51
+ DIM,
52
+ RESET,
53
+ build_card_lines,
54
+ filter_themes,
55
+ find_theme,
56
+ load_themes,
57
+ )
58
+ from synth_shell_theme.tui import (
59
+ print_character_palette_table,
60
+ print_separator_showcase,
61
+ print_side_by_side,
62
+ print_theme_list,
63
+ report_separators_applied,
64
+ report_theme_applied,
65
+ run_separator_tui,
66
+ run_theme_tui,
67
+ )
68
+
69
+
70
+ def _cmd_doctor(as_json: bool = False) -> int:
71
+ summary = system_summary()
72
+ patches = inspect_patches()
73
+ state = read_current_state()
74
+ greeter = read_greeter_state()
75
+ report = {
76
+ "version": __version__,
77
+ "system": summary,
78
+ "patches": patches,
79
+ "active_theme": state["active_theme"],
80
+ "active_theme_id": state["active_theme_id"],
81
+ "internal_separator": state["internal_separator"],
82
+ "end_separator": state["end_separator"],
83
+ "greeter": greeter,
84
+ }
85
+ if as_json:
86
+ print(json.dumps(report, indent=2, ensure_ascii=False))
87
+ return 0
88
+
89
+ ok_tag = "\033[32;1mOK\033[0m"
90
+ warn_tag = "\033[33;1mMISSING\033[0m"
91
+ opt_tag = "\033[36;1mOPTIONAL\033[0m"
92
+
93
+ loc = summary.get("locale", {})
94
+ nf = summary.get("nerd_fonts", {})
95
+ term = summary.get("terminal", {})
96
+ loc_ok = bool(isinstance(loc, dict) and loc.get("utf8"))
97
+ nf_ok = bool(isinstance(nf, dict) and nf.get("detected"))
98
+ tc_ok = bool(isinstance(term, dict) and term.get("truecolor"))
99
+ t256_ok = bool(isinstance(term, dict) and term.get("term_256"))
100
+
101
+ print()
102
+ print(f" {BOLD}Synth-Shell Theme Doctor{RESET} (v{__version__})")
103
+ print(f" {DIM}{'─' * 62}{RESET}")
104
+ print(f" OS / Python: {summary['os']} ({summary['python']})")
105
+ custom_cnt = int(summary.get("custom_themes", 0) or 0)
106
+ custom_note = f" + {custom_cnt} custom" if custom_cnt else ""
107
+ print(f" Bundled themes: {summary['bundled_themes']} themes{custom_note} + {len(ALL_PRESETS)} separator presets")
108
+ print(f" Config file: {summary['config_path']} [{ok_tag if summary['config_exists'] else warn_tag}]")
109
+ print(f" Root config: {summary['root_config_path']} [{ok_tag if summary['root_config_exists'] else opt_tag}]")
110
+ print(f" Prompt script: {summary['prompt_script_path']} [{ok_tag if summary['prompt_script_exists'] else warn_tag}]")
111
+ print(f" Greeter config: {summary['greeter_config_path']} [{ok_tag if summary['greeter_config_exists'] else opt_tag}]")
112
+ print(f" Backups saved: {summary['backup_count']} ({summary['backup_dir']})")
113
+ print(f" Active theme: {state['active_theme'] or 'None detected'}")
114
+ int_sep = state["internal_separator"]
115
+ end_sep = state["end_separator"]
116
+ print(
117
+ f" Separators: internal={int_sep['glyph']} ({int_sep['code']}) " # type: ignore[index]
118
+ f"end={end_sep['glyph']} ({end_sep['code']})" # type: ignore[index]
119
+ )
120
+ print(
121
+ f" UTF-8 Locale: {loc.get('effective', 'unknown') if isinstance(loc, dict) else 'unknown'} "
122
+ f"[{ok_tag if loc_ok else warn_tag}]"
123
+ )
124
+ if isinstance(term, dict):
125
+ color_mode = "24-bit TrueColor" if tc_ok else ("256-color" if t256_ok else "basic")
126
+ print(
127
+ f" Terminal / Color: TERM={term.get('term')} COLORTERM={term.get('colorterm')} "
128
+ f"({color_mode}) [{ok_tag if t256_ok else warn_tag}]"
129
+ )
130
+ if term.get("blesh_detected"):
131
+ print(f" ble.sh detected: yes (tip: enable transient prompt with `--transient`)")
132
+ if term.get("is_vscode"):
133
+ print(f" VS Code font tip: {term.get('vscode_font_setting')}")
134
+ if nf_ok and isinstance(nf, dict):
135
+ samples = ", ".join(str(x) for x in list(nf.get("samples", []))[:3]) # type: ignore[arg-type]
136
+ print(f" Nerd/PL Fonts: {nf.get('count', 0)} found ({samples}) [{ok_tag}]")
137
+ else:
138
+ print(f" Nerd/PL Fonts: none detected [{warn_tag}] (tip: run `synth-shell-theme --ascii-safe`)")
139
+
140
+ print()
141
+ print(f" {BOLD}Runtime Patches & Optimizations:{RESET}")
142
+ patch_labels = [
143
+ ("kube_fast", "Zero-subshell Kubernetes reader + max_kube_char (no yq)"),
144
+ ("kube_namespace_prod", "Kubernetes namespace + automatic 🚨 prod cluster red warning"),
145
+ ("git_single_pass", "Single-pass `git status --porcelain -b` (4x speedup)"),
146
+ ("git_wsl_fast", "WSL2 /mnt/* fast-untracked + timeout + async cache + max_git_char"),
147
+ ("git_ahead_behind_counts", "Exact Git ahead/behind counts (↑N ↓M) with zero extra forks"),
148
+ ("git_advanced_state", "Git rebase/merge/cherry-pick/bisect & worktree detection"),
149
+ ("zero_fork_render", "Zero-fork pure-Bash segment renderer (eliminates ~20 subshells)"),
150
+ ("dual_separator", "Independent ending separator (`separator_char_end`)"),
151
+ ("color_256_parity", "Full 0-255 & 16-named-color parity + italic/regular effects"),
152
+ ("truecolor_24bit", "24-bit TrueColor (#RRGGBB) with automatic 256-color fallback"),
153
+ ("v11_segments", "v1.1 segments (STATUS, DURATION, AWS, GCP, DOCKER, NODE, SSH, prefix, title)"),
154
+ ("v12_segments", "v1.2 segments (JOBS, DIRENV, SHLVL/NIX, RUST, GO) + nounset safety"),
155
+ ("v13_segments", "v1.3 BATTERY segment + Git state + RPROMPT top bar + OSC 133"),
156
+ ("osc133_semantic", "OSC 133 semantic prompt markers (Ghostty/Kitty/WezTerm/WT/VS Code)"),
157
+ ("osc7_cwd", "OSC 7 CWD reporting (new tabs & splits inherit directory)"),
158
+ ("v139_smart_features", "v1.3.9 smart colors (Git/SSH), SUDO/JJ/CUSTOM, Fish PWD & OSC 9 notify"),
159
+ ("terminal_sanitize", "Auto-sanitize leaked SSH/TUI mouse tracking & focus reporting on prompt"),
160
+ ("right_prompt", "Right-aligned top bar (`right_format` + connector fill line)"),
161
+ ("responsive_width", "Responsive compact layout on narrow tmux/VS Code splits (<90 cols)"),
162
+ ("hook_chaining", "Safe PROMPT_COMMAND chaining + PS0 reset (direnv/zoxide/atuin/ble.sh safe)"),
163
+ ("pyenv_enhanced", "Pure-Bash VIRTUAL_ENV_PROMPT / pyvenv.cfg / Conda + max_pyenv_char"),
164
+ ("utf8_ps1_guard", "UTF-8 PS1 escape guard (fixes \\uE0B0 username bug under LC_ALL=C)"),
165
+ ("interactive_guard", "Non-interactive shell safety guard (`scp`/`sftp`/`rsync` safe)"),
166
+ ]
167
+ for key, desc in patch_labels:
168
+ badge = ok_tag if patches.get(key) else warn_tag
169
+ print(f" [{badge}] {desc}")
170
+ if patches.get("greeter_script_found"):
171
+ for key, desc in (
172
+ ("greeter_amd_temp", "Greeter AMD k10temp/Tctl CPU sensor + LC_ALL=C fix"),
173
+ ("greeter_zfs_arc", "Greeter ZFS ARC reclaimable memory accounting fix"),
174
+ ):
175
+ badge = ok_tag if patches.get(key) else warn_tag
176
+ print(f" [{badge}] {desc}")
177
+ if not patches.get("all_applied") and summary["prompt_script_exists"]:
178
+ print()
179
+ print(f" Tip: Run {BOLD}synth-shell-theme init{RESET} to apply missing runtime optimizations.")
180
+ print()
181
+ return 0
182
+
183
+
184
+ def _cmd_init(
185
+ install_missing: bool = False,
186
+ tune_defaults: bool = True,
187
+ theme_choice: str | None = None,
188
+ sync_root: bool = False,
189
+ sync_greeter: bool = False,
190
+ ascii_safe: bool = False,
191
+ ) -> int:
192
+ prompt_sh = get_prompt_script_path()
193
+ if not prompt_sh.is_file() and install_missing:
194
+ print(" Installing upstream synth-shell into ~/.config/synth-shell ...")
195
+ if install_upstream_synth_shell():
196
+ print(" \033[32;1m✓\033[0m Upstream synth-shell installed.")
197
+ else:
198
+ print(" \033[31;1m✗\033[0m Failed to install upstream synth-shell automatically.")
199
+ return 1
200
+
201
+ res = apply_runtime_patches(tune_defaults=tune_defaults)
202
+ changes = list(res["changes"]) # type: ignore[arg-type]
203
+ status = res["status"]
204
+
205
+ selected_theme: dict[str, object] | None = None
206
+ if theme_choice:
207
+ themes = load_themes()
208
+ found, _ = find_theme(theme_choice, themes)
209
+ if not found:
210
+ print(f"Error: Theme '{theme_choice}' not found.", file=sys.stderr)
211
+ return 1
212
+ apply_theme(found)
213
+ selected_theme = found
214
+ changes.append(f"theme:{found['name']}")
215
+
216
+ if ascii_safe:
217
+ apply_ascii_safe_mode()
218
+ changes.append("ascii_safe")
219
+
220
+ if sync_root:
221
+ sync_root_config(theme=selected_theme)
222
+ changes.append("sync_root")
223
+
224
+ if sync_greeter:
225
+ sync_greeter_theme(theme=selected_theme, hide_swap_if_unavailable=True)
226
+ changes.append("sync_greeter")
227
+
228
+ print()
229
+ print(f" {BOLD}Synth-Shell Runtime Initialization (v{__version__}){RESET}")
230
+ if changes:
231
+ for item in changes:
232
+ print(f" \033[32;1m✓\033[0m Applied: {item}")
233
+ else:
234
+ print(" \033[32;1m✓\033[0m All runtime patches and defaults already up to date.")
235
+ if isinstance(status, dict) and not status.get("prompt_script_found"):
236
+ print(
237
+ f" \033[33;1m!\033[0m {prompt_sh} not found yet "
238
+ "(run `synth-shell-theme init --install` to install upstream synth-shell)."
239
+ )
240
+ print()
241
+ return 0
242
+
243
+
244
+ def main_separator(argv: list[str] | None = None) -> int:
245
+ """Dedicated CLI entry point for `synth-shell-separator` (and `synth-shell-theme sep`)."""
246
+ setup_console()
247
+ parser = argparse.ArgumentParser(
248
+ prog="synth-shell-separator",
249
+ description="Interactive Powerline & Nerd Font dual separator editor for synth-shell.",
250
+ )
251
+ parser.add_argument("-l", "--list", action="store_true", help="List all 48 separator presets with live prompt previews")
252
+ parser.add_argument("-c", "--current", action="store_true", help="Show currently active internal and ending separators")
253
+ parser.add_argument("-T", "--palette", action="store_true", help="Display visual cheat-sheet table of 60+ Nerd Font glyphs")
254
+ parser.add_argument("-a", "--apply", metavar="SEP", help=f"Apply separator to both internal & ending positions (1-{len(ALL_PRESETS)}, name, hex, or glyph)")
255
+ parser.add_argument("-d", "--dual", nargs=2, metavar=("INTERNAL", "ENDING"), help="Set independent internal and ending separators (e.g. --dual round arrow)")
256
+ parser.add_argument("-i", "--internal", metavar="SEP", help="Set internal segment separator only")
257
+ parser.add_argument("-e", "--end", metavar="SEP", help="Set final ending separator only")
258
+ parser.add_argument("-u", "--custom", metavar="CHAR_OR_HEX", help="Apply custom Unicode hex (e.g. E0B4, U+F0E7) or glyph")
259
+ parser.add_argument("-p", "--preview", metavar="SEP", help="Preview sample prompt with a separator without saving")
260
+ parser.add_argument("--preview-dual", nargs=2, metavar=("INTERNAL", "ENDING"), help="Preview sample prompt with dual separators without saving")
261
+ parser.add_argument("-r", "--random", action="store_true", help="Apply a random curated separator preset")
262
+ parser.add_argument("--no-clear", action="store_true", help="Do not clear terminal screen in interactive mode")
263
+
264
+ args = parser.parse_args(argv)
265
+ from synth_shell_theme.tui import _active_preview_theme, render_separator_sample
266
+
267
+ theme = _active_preview_theme()
268
+ (cur_int_glyph, cur_int_code), end_tuple = detect_current_separators()
269
+ cur_end_glyph = end_tuple[0] if end_tuple else cur_int_glyph
270
+ cur_end_code = end_tuple[1] if end_tuple else cur_int_code
271
+
272
+ if args.current:
273
+ end_desc = f" ({cur_end_code})" if end_tuple else " (same as internal)"
274
+ print(f"Internal separator: {BOLD}{cur_int_glyph}{RESET} ({cur_int_code})")
275
+ print(f"Ending separator: {BOLD}{cur_end_glyph}{RESET}{end_desc}")
276
+ print(f"Sample: {render_separator_sample(cur_int_glyph, theme, cur_end_glyph)}")
277
+ return 0
278
+
279
+ if args.palette:
280
+ print_character_palette_table()
281
+ return 0
282
+
283
+ if args.list:
284
+ print_separator_showcase(theme, cur_int_glyph)
285
+ return 0
286
+
287
+ if args.preview_dual:
288
+ g1, c1, l1 = resolve_separator_input(args.preview_dual[0])
289
+ g2, c2, l2 = resolve_separator_input(args.preview_dual[1])
290
+ print()
291
+ print(f" Internal: {BOLD}{g1}{RESET} ({c1}) — {l1}")
292
+ print(f" Ending: {BOLD}{g2}{RESET} ({c2}) — {l2}")
293
+ print(f" Preview: {render_separator_sample(g1, theme, g2)}")
294
+ print()
295
+ return 0
296
+
297
+ if args.preview:
298
+ g, c, label = resolve_separator_input(args.preview)
299
+ print()
300
+ print(f" Separator: {BOLD}{g}{RESET} ({c}) — {label}")
301
+ print(f" Preview: {render_separator_sample(g, theme, g)}")
302
+ print()
303
+ return 0
304
+
305
+ if args.dual:
306
+ g1, c1, l1 = resolve_separator_input(args.dual[0])
307
+ g2, c2, l2 = resolve_separator_input(args.dual[1])
308
+ res = apply_separators(internal=(g1, c1), end=(g2, c2))
309
+ report_separators_applied(res, label=f"{l1} + {l2}")
310
+ return 0
311
+
312
+ if args.internal:
313
+ g, c, label = resolve_separator_input(args.internal)
314
+ res = apply_separators(internal=(g, c))
315
+ report_separators_applied(res, label=f"Internal: {label}")
316
+ return 0
317
+
318
+ if args.end:
319
+ g, c, label = resolve_separator_input(args.end)
320
+ res = apply_separators(end=(g, c))
321
+ report_separators_applied(res, label=f"Ending: {label}")
322
+ return 0
323
+
324
+ if args.random:
325
+ key, glyph, code, desc = random.choice(ALL_PRESETS)
326
+ res = apply_separators(internal=(glyph, code), end=(glyph, code))
327
+ report_separators_applied(res, label=f"{key} ({desc})")
328
+ return 0
329
+
330
+ target = args.custom or args.apply
331
+ if target:
332
+ g, c, label = resolve_separator_input(target)
333
+ res = apply_separators(internal=(g, c), end=(g, c))
334
+ report_separators_applied(res, label=label)
335
+ return 0
336
+
337
+ run_separator_tui(clear_screen=not args.no_clear)
338
+ return 0
339
+
340
+
341
+ def main(argv: list[str] | None = None) -> int:
342
+ """Primary CLI entry point for `synth-shell-theme`."""
343
+ setup_console()
344
+ raw_args = list(sys.argv[1:] if argv is None else argv)
345
+
346
+ if raw_args:
347
+ sub = raw_args[0].lower()
348
+ rest = raw_args[1:]
349
+
350
+ if sub in ("sep", "separator", "separators"):
351
+ return main_separator(rest)
352
+
353
+ if sub in ("web", "studio"):
354
+ web_parser = argparse.ArgumentParser(
355
+ prog="synth-shell-theme web",
356
+ description="Launch the local interactive Synth-Shell Theme Web Studio.",
357
+ )
358
+ web_parser.add_argument("--host", default="127.0.0.1", help="Bind address (default: 127.0.0.1)")
359
+ web_parser.add_argument("-p", "--port", type=int, default=7778, help="Preferred port (default: 7778)")
360
+ web_parser.add_argument("--no-browser", action="store_true", help="Do not automatically open web browser")
361
+ w_args = web_parser.parse_args(rest)
362
+ from synth_shell_theme.server import run_studio_server
363
+
364
+ run_studio_server(host=w_args.host, port=w_args.port, open_browser=not w_args.no_browser)
365
+ return 0
366
+
367
+ if sub == "init":
368
+ init_parser = argparse.ArgumentParser(
369
+ prog="synth-shell-theme init",
370
+ description="Apply idempotent runtime, speed, segment & safety patches to synth-shell.",
371
+ )
372
+ init_parser.add_argument("--install", action="store_true", help="Clone & install upstream synth-shell if missing")
373
+ init_parser.add_argument("--no-tune", action="store_true", help="Do not update default max_pwd_char / 2-line config options")
374
+ init_parser.add_argument("-a", "--apply", metavar="THEME", help="Also apply a theme by number or slug")
375
+ init_parser.add_argument("--ascii-safe", action="store_true", help="Switch separators and Git symbols to ASCII-safe mode")
376
+ init_parser.add_argument("--sync-root", action="store_true", help="Also generate/sync synth-shell-prompt.root.config")
377
+ init_parser.add_argument("--sync-greeter", action="store_true", help="Also sync active palette to synth-shell-greeter.config")
378
+ i_args = init_parser.parse_args(rest)
379
+ return _cmd_init(
380
+ install_missing=i_args.install,
381
+ tune_defaults=not i_args.no_tune,
382
+ theme_choice=i_args.apply,
383
+ sync_root=i_args.sync_root,
384
+ sync_greeter=i_args.sync_greeter,
385
+ ascii_safe=i_args.ascii_safe,
386
+ )
387
+
388
+ if sub == "doctor":
389
+ doc_parser = argparse.ArgumentParser(
390
+ prog="synth-shell-theme doctor",
391
+ description="Inspect synth-shell paths, locale, Nerd Fonts, terminal capabilities, backups & patches.",
392
+ )
393
+ doc_parser.add_argument("--json", action="store_true", help="Output diagnostics as JSON")
394
+ doc_parser.add_argument("--fix", action="store_true", help="Auto-repair CRLF endings and apply all missing runtime patches")
395
+ doc_parser.add_argument("--auto-ascii", action="store_true", help="With --fix, also switch to ASCII-safe if UTF-8/Nerd Fonts are missing")
396
+ d_args = doc_parser.parse_args(rest)
397
+ if d_args.fix:
398
+ fres = doctor_fix(auto_ascii=d_args.auto_ascii)
399
+ if not d_args.json:
400
+ actions = fres["actions"]
401
+ if actions:
402
+ print(f"\n {BOLD}Doctor Auto-Fix Applied:{RESET}")
403
+ for act in actions: # type: ignore[union-attr]
404
+ print(f" \033[32;1m✓\033[0m {act}")
405
+ else:
406
+ print(f"\n \033[32;1m✓\033[0m Everything is already healthy!")
407
+ return _cmd_doctor(as_json=d_args.json)
408
+
409
+ if sub in ("import-theme", "import-palette"):
410
+ it_parser = argparse.ArgumentParser(
411
+ prog="synth-shell-theme import-theme",
412
+ description="Import external color palettes (Pywal, Base16 YAML, Ghostty, Kitty, Alacritty, Windows Terminal JSON).",
413
+ )
414
+ it_parser.add_argument("source", nargs="?", default=None, help="Path to palette file (omit when using --pywal)")
415
+ it_parser.add_argument("--pywal", action="store_true", help="Import active colors from ~/.cache/wal/colors.json")
416
+ it_parser.add_argument("--name", default=None, help="Custom name for the imported theme")
417
+ it_parser.add_argument("--no-apply", action="store_true", help="Save to ~/.config/synth-shell/themes/ without applying immediately")
418
+ it_args = it_parser.parse_args(rest)
419
+ res_it = import_external_theme(
420
+ source_path=Path(it_args.source) if it_args.source else None,
421
+ from_pywal=it_args.pywal,
422
+ custom_name=it_args.name,
423
+ apply_now=not it_args.no_apply,
424
+ )
425
+ print(f"Imported {res_it['format']} theme '{res_it['theme']}' -> {res_it['saved_path']}")
426
+ return 0
427
+
428
+ if sub in ("export-web", "export-static"):
429
+ ew_parser = argparse.ArgumentParser(
430
+ prog="synth-shell-theme export-web",
431
+ description="Export a standalone static HTML demo of the Web Studio (for GitHub Pages).",
432
+ )
433
+ ew_parser.add_argument("output", nargs="?", default="docs/index.html", help="Output HTML file (default: docs/index.html)")
434
+ ew_args = ew_parser.parse_args(rest)
435
+ out_html = export_static_studio(Path(ew_args.output))
436
+ print(f"Exported standalone static Web Studio demo to {out_html}")
437
+ return 0
438
+
439
+ if sub in ("export-starship", "starship"):
440
+ es_parser = argparse.ArgumentParser(
441
+ prog="synth-shell-theme export-starship",
442
+ description="Export the active theme & dual Powerline separators to a starship.toml preset.",
443
+ )
444
+ es_parser.add_argument("output", nargs="?", default="~/.config/starship.toml", help="Destination starship.toml path")
445
+ es_args = es_parser.parse_args(rest)
446
+ res_es = export_starship_toml(Path(es_args.output))
447
+ print(f"Exported Starship preset ({res_es['theme']}) -> {res_es['dest']}")
448
+ return 0
449
+
450
+ if sub in ("ssh-install", "ssh-deploy"):
451
+ ssh_parser = argparse.ArgumentParser(
452
+ prog="synth-shell-theme ssh-install",
453
+ description="Deploy patched synth-shell-prompt.sh + active config to a remote host over SSH (no Python/Git required remotely).",
454
+ )
455
+ ssh_parser.add_argument("target", help="SSH destination (e.g. user@server)")
456
+ ssh_parser.add_argument("-p", "--port", type=int, default=None, help="SSH port")
457
+ ssh_parser.add_argument("--ascii-safe", action="store_true", help="Convert separators & Git symbols to ASCII-safe for remote host")
458
+ ssh_parser.add_argument("--no-host-color", action="store_true", help="Do not enable automatic SSH hostname color on remote host")
459
+ ssh_parser.add_argument("--dry-run", action="store_true", help="Build deployment payload without connecting over SSH")
460
+ s_args = ssh_parser.parse_args(rest)
461
+ res_ssh = ssh_install_remote(
462
+ target=s_args.target,
463
+ ascii_safe=s_args.ascii_safe,
464
+ ssh_port=s_args.port,
465
+ ssh_host_color=not s_args.no_host_color,
466
+ dry_run=s_args.dry_run,
467
+ )
468
+ mode_lbl = "[DRY-RUN] " if res_ssh["dry_run"] else ""
469
+ print(
470
+ f"{mode_lbl}Deployed synth-shell prompt to {res_ssh['target']} "
471
+ f"(script={res_ssh['script_bytes']}B, config={res_ssh['config_bytes']}B, ascii_safe={res_ssh['ascii_safe']})"
472
+ )
473
+ return 0
474
+
475
+ if sub in ("bench", "benchmark"):
476
+ bench_parser = argparse.ArgumentParser(
477
+ prog="synth-shell-theme bench",
478
+ description="Benchmark live Bash prompt_command_hook rendering latency (p50 / p95 in ms).",
479
+ )
480
+ bench_parser.add_argument("-n", "--runs", type=int, default=15, help="Number of prompt iterations (default: 15)")
481
+ bench_parser.add_argument("--json", action="store_true", help="Output benchmark metrics as JSON")
482
+ b_args = bench_parser.parse_args(rest)
483
+ bres = benchmark_prompt(iterations=b_args.runs)
484
+ if b_args.json:
485
+ print(json.dumps(bres, indent=2, ensure_ascii=False))
486
+ return 0 if bres.get("ok") else 1
487
+ if not bres.get("ok"):
488
+ print(f"Benchmark error: {bres.get('error')}", file=sys.stderr)
489
+ return 1
490
+ print()
491
+ print(f" {BOLD}Synth-Shell Prompt Benchmark{RESET} ({bres['iterations']} runs in {bres['cwd']})")
492
+ print(f" {DIM}{'─' * 56}{RESET}")
493
+ print(f" Min: \033[32;1m{bres['min_ms']} ms\033[0m")
494
+ print(f" Median: \033[36;1m{bres['p50_ms']} ms\033[0m (p50)")
495
+ print(f" p95: \033[33;1m{bres['p95_ms']} ms\033[0m")
496
+ print(f" Max: {bres['max_ms']} ms")
497
+ print()
498
+ return 0
499
+
500
+ if sub in ("completion", "completions"):
501
+ comp_parser = argparse.ArgumentParser(
502
+ prog="synth-shell-theme completion",
503
+ description="Output shell tab-completion script (currently supports: bash).",
504
+ )
505
+ comp_parser.add_argument("shell", nargs="?", default="bash", choices=("bash",), help="Target shell (default: bash)")
506
+ comp_parser.parse_args(rest)
507
+ print(generate_bash_completion())
508
+ return 0
509
+
510
+ if sub == "export":
511
+ exp_parser = argparse.ArgumentParser(
512
+ prog="synth-shell-theme export",
513
+ description="Export active theme colors, separators, and layout options to a JSON file.",
514
+ )
515
+ exp_parser.add_argument("output", help="Destination JSON file path")
516
+ e_args = exp_parser.parse_args(rest)
517
+ out = export_preset(Path(e_args.output))
518
+ print(f"Exported preset to {out}")
519
+ return 0
520
+
521
+ if sub == "import":
522
+ imp_parser = argparse.ArgumentParser(
523
+ prog="synth-shell-theme import",
524
+ description="Import and apply a JSON preset file.",
525
+ )
526
+ imp_parser.add_argument("input", help="Source JSON preset file path")
527
+ im_args = imp_parser.parse_args(rest)
528
+ res = import_preset(Path(im_args.input))
529
+ print(f"Imported preset from {res['imported_from']}")
530
+ return 0
531
+
532
+ if sub == "tui":
533
+ raw_args = rest
534
+
535
+ parser = argparse.ArgumentParser(
536
+ prog="synth-shell-theme",
537
+ description=(
538
+ "Interactive 256-color Prompt Theme Picker (64 themes), Dual Powerline Separator Editor, "
539
+ "Runtime Speed & Telemetry Optimizer, and Live Web Studio for synth-shell."
540
+ ),
541
+ epilog=(
542
+ "Subcommands:\n"
543
+ " synth-shell-theme Launch interactive 2-column TUI\n"
544
+ " synth-shell-theme web Launch live browser-based Web Studio (port 7778)\n"
545
+ " synth-shell-theme sep Launch interactive Dual Separator & 60+ Glyph Editor\n"
546
+ " synth-shell-theme init Apply all v1.2 runtime, speed, TrueColor & hook-chaining patches\n"
547
+ " synth-shell-theme doctor Check config, locale, Nerd Fonts, TERM, backups & patch health\n"
548
+ " synth-shell-theme bench Measure live prompt_command_hook latency (p50 / p95 ms)\n"
549
+ " synth-shell-theme completion Print Bash tab-completion script\n"
550
+ " synth-shell-theme export FILE Export current setup as a portable JSON preset\n"
551
+ " synth-shell-theme import FILE Import and apply a JSON preset"
552
+ ),
553
+ formatter_class=argparse.RawDescriptionHelpFormatter,
554
+ )
555
+ parser.add_argument("-v", "--version", action="version", version=f"synth-shell-theme {__version__}")
556
+ parser.add_argument("-l", "--list", action="store_true", help="List all 64 themes with 256-color swatches and exit")
557
+ parser.add_argument("-c", "--current", action="store_true", help="Print currently active theme & separators and exit")
558
+ parser.add_argument("-a", "--apply", metavar="THEME", help="Apply theme by number (1-64) or name/slug and exit")
559
+ parser.add_argument("--force-white-text", action="store_true", help="Force segment text to white for maximum contrast")
560
+ parser.add_argument("--keep-input", action="store_true", help="Preserve existing font_color_input when applying a theme")
561
+ parser.add_argument("-S", "--separators", action="store_true", help="Showcase all 48 Powerline & Nerd Font separator presets")
562
+ parser.add_argument("-T", "--palette", action="store_true", help="Display visual cheat-sheet table of 60+ Nerd Font glyphs")
563
+ parser.add_argument("-t", "--separator", metavar="SEP", help="Apply separator style to both internal & ending positions")
564
+ parser.add_argument("-d", "--dual", nargs=2, metavar=("INTERNAL", "ENDING"), help="Apply independent internal and ending separators")
565
+ parser.add_argument("--internal", metavar="SEP", help="Set internal segment separator only")
566
+ parser.add_argument("--end", metavar="SEP", help="Set final ending separator only")
567
+ parser.add_argument("--format", metavar="SEGMENTS", help='Set left prompt segments (e.g. "HOST PWD GIT PYENV TF KUBE")')
568
+ parser.add_argument("--right-format", default=None, metavar="SEGMENTS", help='Set right-aligned top bar segments (e.g. "STATUS DURATION KUBE CLOCK BATTERY", "" to clear)')
569
+ parser.add_argument("--right-fill", default=None, metavar="CHAR", help='Connector character between left & right prompt bars (default: "─")')
570
+ parser.add_argument("--osc133", dest="osc133", action="store_true", default=None, help="Enable OSC 133 semantic prompt markers (Ghostty/Kitty/WezTerm/WT/VS Code)")
571
+ parser.add_argument("--no-osc133", dest="osc133", action="store_false", help="Disable OSC 133 semantic prompt markers")
572
+ parser.add_argument("--osc7", dest="osc7", action="store_true", default=None, help="Enable OSC 7 CWD reporting so new tabs/splits inherit directory")
573
+ parser.add_argument("--no-osc7", dest="osc7", action="store_false", help="Disable OSC 7 CWD reporting")
574
+ parser.add_argument("--terminal-sanitize", dest="terminal_sanitize", action="store_true", default=None, help="Auto-disable leaked SSH/TUI mouse tracking & focus reporting on prompt return")
575
+ parser.add_argument("--no-terminal-sanitize", dest="terminal_sanitize", action="store_false", help="Disable automatic terminal mode sanitization on prompt return")
576
+ parser.add_argument("--kube-ns", dest="kube_ns", action="store_true", default=None, help="Show active Kubernetes namespace alongside context")
577
+ parser.add_argument("--no-kube-ns", dest="kube_ns", action="store_false", help="Hide Kubernetes namespace")
578
+ parser.add_argument("--kube-prod-warn", dest="kube_prod_warn", action="store_true", default=None, help="Highlight production Kubernetes contexts in red with 🚨")
579
+ parser.add_argument("--no-kube-prod-warn", dest="kube_prod_warn", action="store_false", help="Disable production Kubernetes red warning highlight")
580
+ parser.add_argument("--kube-prod-pattern", default=None, metavar="REGEX", help='Regex matching production kube contexts/namespaces (default: "prod|production|prd|live")')
581
+ parser.add_argument("--git-dynamic-color", dest="git_dynamic_color", action="store_true", default=None, help="Dynamically color GIT segment amber when dirty & red on rebase/merge")
582
+ parser.add_argument("--no-git-dynamic-color", dest="git_dynamic_color", action="store_false", help="Keep static theme color for GIT segment")
583
+ parser.add_argument("--ssh-host-color", dest="ssh_host_color", action="store_true", default=None, help="Auto-color HOST segment by hostname hash / prod-stg rule over SSH")
584
+ parser.add_argument("--no-ssh-host-color", dest="ssh_host_color", action="store_false", help="Keep static theme color for HOST segment over SSH")
585
+ parser.add_argument("--pwd-style", choices=("default", "fish"), default=None, help="Path shortening style: default or fish (~/p/repo)")
586
+ parser.add_argument("--notify-sec", type=int, default=None, metavar="SEC", help="Emit OSC 9/99 desktop notification when command exceeds SEC seconds (0=off)")
587
+ parser.add_argument("--custom-badge", default=None, metavar="TEXT", help='Static text for CUSTOM segment (or set $SYNTH_CUSTOM_BADGE dynamically)')
588
+ parser.add_argument("--auto-theme", action="store_true", help="Auto-detect OS dark/light mode and apply configured Dark or Light theme")
589
+ parser.add_argument("--git-state", dest="git_state", action="store_true", default=None, help="Show Git rebase/merge/cherry-pick/bisect & worktree state")
590
+ parser.add_argument("--no-git-state", dest="git_state", action="store_false", help="Hide Git rebase/merge/worktree state")
591
+ parser.add_argument("--battery-threshold", type=int, default=None, metavar="PCT", help="Only show BATTERY segment at or below PCT%% (default: 100)")
592
+ parser.add_argument("--sync-ecosystem", action="store_true", help="Generate theme-env.sh (FZF_DEFAULT_OPTS + LS_COLORS) & tmux-theme.conf")
593
+ parser.add_argument("--two-line", dest="two_line", action="store_true", default=None, help="Enable 2-line command prompt")
594
+ parser.add_argument("--single-line", dest="two_line", action="store_false", help="Enable compact 1-line command prompt")
595
+ parser.add_argument("--max-pwd", type=int, default=None, metavar="N", help="Max PWD display length (10-120)")
596
+ parser.add_argument("--max-git", type=int, default=None, metavar="N", help="Max Git branch length (0=unlimited, or 4-80)")
597
+ parser.add_argument("--max-pyenv", type=int, default=None, metavar="N", help="Max Python/Conda env name length (0=unlimited, or 4-60)")
598
+ parser.add_argument("--max-kube", type=int, default=None, metavar="N", help="Max Kubernetes context length (0=unlimited, or 4-60)")
599
+ parser.add_argument("--compact-width", type=int, default=None, metavar="COLS", help="Hide secondary segments when terminal width < COLS (default 90, 0=off)")
600
+ parser.add_argument("--git-counts", dest="git_counts", action="store_true", default=None, help="Show exact Git ahead/behind counts (↑N ↓M)")
601
+ parser.add_argument("--no-git-counts", dest="git_counts", action="store_false", help="Hide exact Git ahead/behind counts")
602
+ parser.add_argument("--transient", dest="transient", action="store_true", default=None, help="Enable ble.sh transient prompt trimming when ble.sh is loaded")
603
+ parser.add_argument("--no-transient", dest="transient", action="store_false", help="Disable ble.sh transient prompt trimming")
604
+ parser.add_argument("--toggle-theme", action="store_true", help="Toggle between configured Light and Dark themes in 1 command")
605
+ parser.add_argument("--light-theme", default=None, metavar="THEME", help="Preferred Light theme slug for --toggle-theme (default: catppuccin-latte)")
606
+ parser.add_argument("--dark-theme", default=None, metavar="THEME", help="Preferred Dark theme slug for --toggle-theme (default: tokyo-night)")
607
+ parser.add_argument("--prefix", default=None, metavar="TEXT", help='Leading prompt prefix icon/string (use "auto" for OS icon, "" to clear)')
608
+ parser.add_argument("--text-effect", choices=VALID_FONT_EFFECTS, default=None, help="Global segment text effect (bold, regular, italic, dim, none)")
609
+ parser.add_argument("--terminal-title", dest="terminal_title", action="store_true", default=None, help="Enable OSC-0 terminal tab/window title updates")
610
+ parser.add_argument("--no-terminal-title", dest="terminal_title", action="store_false", help="Disable OSC-0 terminal title updates")
611
+ parser.add_argument("--fast-git-wsl", dest="fast_git_wsl", action="store_true", default=None, help="Skip untracked files on WSL /mnt/* drives")
612
+ parser.add_argument("--no-fast-git-wsl", dest="fast_git_wsl", action="store_false", help="Scan untracked files even on WSL /mnt/* drives")
613
+ parser.add_argument("--git-timeout", type=int, default=None, metavar="MS", help="Git status timeout in ms (0=disabled, e.g. 500)")
614
+ parser.add_argument("--async-git", dest="async_git", action="store_true", default=None, help="Enable asynchronous background Git status cache")
615
+ parser.add_argument("--no-async-git", dest="async_git", action="store_false", help="Disable asynchronous Git status cache")
616
+ parser.add_argument("--min-duration", type=int, default=None, metavar="MS", help="Minimum command runtime in ms to display DURATION segment (default 2000)")
617
+ parser.add_argument("--ascii-safe", action="store_true", help="Use ASCII-safe separators & Git symbols (for SSH hosts without Nerd Fonts)")
618
+ parser.add_argument("--sync-root", action="store_true", help="Generate/sync synth-shell-prompt.root.config from active theme")
619
+ parser.add_argument("--sync-greeter", action="store_true", help="Sync active theme palette to synth-shell-greeter.config")
620
+ parser.add_argument("--greeter-monitors", default=None, metavar="LIST", help='Set greeter monitors (e.g. "OS KERNEL CPU MEMORY_MON HDDROOT_MON")')
621
+ parser.add_argument("--hide-swap", action="store_true", help="Hide SWAP_MON in greeter config when host has no swap")
622
+ parser.add_argument("-r", "--random", action="store_true", help="Apply a random theme and exit")
623
+ parser.add_argument("-s", "--search", metavar="TERM", help="Search themes by name, slug, or badge and exit")
624
+ parser.add_argument("-w", "--web", action="store_true", help="Launch live interactive Web Studio in your browser")
625
+ parser.add_argument("--port", type=int, default=7778, help="Port for --web server (default: 7778)")
626
+ parser.add_argument("--no-browser", action="store_true", help="Do not open browser automatically with --web")
627
+ parser.add_argument("-b", "--backup", action="store_true", help="Create a timestamped backup of synth-shell-prompt.config")
628
+ parser.add_argument("--backups", action="store_true", help="List available configuration backups")
629
+ parser.add_argument("-u", "--restore", nargs="?", const="1", metavar="ID_OR_NAME", help="Restore latest (or specified) backup")
630
+ parser.add_argument("--no-clear", action="store_true", help="Do not clear screen between pages in TUI mode")
631
+
632
+ args = parser.parse_args(raw_args)
633
+ themes = load_themes()
634
+ current_name, current_idx = detect_current_theme(themes)
635
+
636
+ if args.backup:
637
+ bak = backup_config()
638
+ if bak:
639
+ print(f"Backup created: {bak}")
640
+ return 0
641
+ print("No config file found to back up.", file=sys.stderr)
642
+ return 1
643
+
644
+ if args.backups:
645
+ baks = list_backups()
646
+ if not baks:
647
+ print("No backups found.")
648
+ return 0
649
+ print(f"\n {BOLD}Saved Configuration Backups ({len(baks)}):{RESET}")
650
+ for b in baks:
651
+ print(f" #{b['id']:02d} {b['modified']} {b['name']}")
652
+ print()
653
+ return 0
654
+
655
+ if args.restore is not None:
656
+ restored = restore_backup(args.restore)
657
+ if not restored:
658
+ print(f"Error: Backup '{args.restore}' not found.", file=sys.stderr)
659
+ return 1
660
+ print(f"Restored configuration from: {restored}")
661
+ return 0
662
+
663
+ if args.current:
664
+ (int_g, int_c), end_t = detect_current_separators()
665
+ end_g, end_c = end_t if end_t else (int_g, int_c)
666
+ if current_name:
667
+ idx_str = f" (#{current_idx})" if current_idx else ""
668
+ print(f"Current theme: {BOLD}{current_name}{RESET}{idx_str}")
669
+ else:
670
+ print("Current theme: none detected")
671
+ print(f"Internal separator: {BOLD}{int_g}{RESET} ({int_c})")
672
+ print(f"Ending separator: {BOLD}{end_g}{RESET} ({end_c})")
673
+ return 0
674
+
675
+ if args.palette:
676
+ print_character_palette_table()
677
+ return 0
678
+
679
+ if args.separators:
680
+ print_separator_showcase()
681
+ return 0
682
+
683
+ if args.web:
684
+ from synth_shell_theme.server import run_studio_server
685
+
686
+ run_studio_server(port=args.port, open_browser=not args.no_browser)
687
+ return 0
688
+
689
+ if args.list:
690
+ print_theme_list(themes, current_name)
691
+ return 0
692
+
693
+ if args.search:
694
+ matches = filter_themes(args.search, themes)
695
+ if not matches:
696
+ print(f"No themes matching '{args.search}'.")
697
+ return 0
698
+ (sep_int, _), end_t = detect_current_separators()
699
+ sep_end = end_t[0] if end_t else sep_int
700
+ print()
701
+ print(f"{BOLD} Themes matching '{args.search}' ({len(matches)} matches):{RESET}")
702
+ print()
703
+ cards = [
704
+ build_card_lines(t, orig_idx, current_name, sep=sep_int, sep_end=sep_end)
705
+ for orig_idx, t in matches
706
+ ]
707
+ print_side_by_side(cards, 1, 74)
708
+ return 0
709
+
710
+ did_non_interactive = False
711
+ chosen_theme: dict[str, object] | None = None
712
+
713
+ if args.auto_theme:
714
+ res_auto = apply_auto_system_theme(light_theme=args.light_theme, dark_theme=args.dark_theme)
715
+ print(
716
+ f"Auto-detected OS {res_auto['detected_scheme']} mode -> applied "
717
+ f"{BOLD}{res_auto['theme']}{RESET} ({res_auto['config_path']})"
718
+ )
719
+ did_non_interactive = True
720
+ elif args.toggle_theme:
721
+ res_tog = toggle_light_dark_theme(light_slug=args.light_theme, dark_slug=args.dark_theme)
722
+ print(f"Toggled to {res_tog['mode']} theme: {BOLD}{res_tog['theme']}{RESET} ({res_tog['config_path']})")
723
+ did_non_interactive = True
724
+ elif args.random:
725
+ pick_t = random.choice(themes)
726
+ chosen_theme = pick_t
727
+ res = apply_theme(pick_t, force_white=args.force_white_text, keep_input=args.keep_input)
728
+ report_theme_applied(res, force_white=args.force_white_text, keep_input=args.keep_input)
729
+ did_non_interactive = True
730
+ elif args.apply:
731
+ theme, _ = find_theme(args.apply, themes)
732
+ if not theme:
733
+ print(
734
+ f"Error: Theme '{args.apply}' not found. Run `synth-shell-theme --list` to view all 64 themes.",
735
+ file=sys.stderr,
736
+ )
737
+ return 1
738
+ chosen_theme = theme
739
+ res = apply_theme(theme, force_white=args.force_white_text, keep_input=args.keep_input)
740
+ report_theme_applied(res, force_white=args.force_white_text, keep_input=args.keep_input)
741
+ did_non_interactive = True
742
+
743
+ if args.ascii_safe:
744
+ res_ascii = apply_ascii_safe_mode()
745
+ print(f"Applied ASCII-safe separators & Git symbols to {res_ascii['config_path']}")
746
+ did_non_interactive = True
747
+ elif args.dual:
748
+ g1, c1, l1 = resolve_separator_input(args.dual[0])
749
+ g2, c2, l2 = resolve_separator_input(args.dual[1])
750
+ res_s = apply_separators(internal=(g1, c1), end=(g2, c2))
751
+ report_separators_applied(res_s, label=f"{l1} + {l2}")
752
+ did_non_interactive = True
753
+ elif args.separator:
754
+ g, c, label = resolve_separator_input(args.separator)
755
+ res_s = apply_separators(internal=(g, c), end=(g, c))
756
+ report_separators_applied(res_s, label=label)
757
+ did_non_interactive = True
758
+ else:
759
+ if args.internal:
760
+ g, c, label = resolve_separator_input(args.internal)
761
+ res_s = apply_separators(internal=(g, c))
762
+ report_separators_applied(res_s, label=f"Internal: {label}")
763
+ did_non_interactive = True
764
+ if args.end:
765
+ g, c, label = resolve_separator_input(args.end)
766
+ res_s = apply_separators(end=(g, c))
767
+ report_separators_applied(res_s, label=f"Ending: {label}")
768
+ did_non_interactive = True
769
+
770
+ has_layout = any(
771
+ x is not None
772
+ for x in (
773
+ args.format,
774
+ args.right_format,
775
+ args.right_fill,
776
+ args.osc133,
777
+ args.osc7,
778
+ args.terminal_sanitize,
779
+ args.kube_ns,
780
+ args.kube_prod_warn,
781
+ args.kube_prod_pattern,
782
+ args.git_dynamic_color,
783
+ args.ssh_host_color,
784
+ args.pwd_style,
785
+ args.notify_sec,
786
+ args.custom_badge,
787
+ args.git_state,
788
+ args.battery_threshold,
789
+ args.two_line,
790
+ args.max_pwd,
791
+ args.max_git,
792
+ args.max_pyenv,
793
+ args.max_kube,
794
+ args.compact_width,
795
+ args.git_counts,
796
+ args.transient,
797
+ args.light_theme if not args.toggle_theme else None,
798
+ args.dark_theme if not args.toggle_theme else None,
799
+ args.prefix,
800
+ args.text_effect,
801
+ args.terminal_title,
802
+ args.fast_git_wsl,
803
+ args.git_timeout,
804
+ args.async_git,
805
+ args.min_duration,
806
+ )
807
+ )
808
+ if has_layout:
809
+ res_l = apply_layout_options(
810
+ format_str=args.format,
811
+ right_format_str=args.right_format,
812
+ right_fill_char=args.right_fill,
813
+ enable_osc133=args.osc133,
814
+ enable_osc7=args.osc7,
815
+ enable_terminal_sanitize=args.terminal_sanitize,
816
+ kube_show_namespace=args.kube_ns,
817
+ kube_prod_warning=args.kube_prod_warn,
818
+ kube_prod_pattern=args.kube_prod_pattern,
819
+ git_dynamic_color=args.git_dynamic_color,
820
+ ssh_host_color=args.ssh_host_color,
821
+ pwd_style=args.pwd_style,
822
+ notify_duration_sec=args.notify_sec,
823
+ custom_segment_text=args.custom_badge,
824
+ git_show_state=args.git_state,
825
+ battery_threshold=args.battery_threshold,
826
+ new_line=args.two_line,
827
+ max_pwd_char=args.max_pwd,
828
+ max_git_char=args.max_git,
829
+ max_pyenv_char=args.max_pyenv,
830
+ max_kube_char=args.max_kube,
831
+ compact_width=args.compact_width,
832
+ git_show_counts=args.git_counts,
833
+ transient_prompt=args.transient,
834
+ light_theme=args.light_theme if not args.toggle_theme else None,
835
+ dark_theme=args.dark_theme if not args.toggle_theme else None,
836
+ prompt_prefix=args.prefix,
837
+ font_effect=args.text_effect,
838
+ enable_terminal_title=args.terminal_title,
839
+ git_skip_untracked_on_slow_fs=args.fast_git_wsl,
840
+ git_timeout_ms=args.git_timeout,
841
+ git_async_cache=args.async_git,
842
+ min_duration_ms=args.min_duration,
843
+ )
844
+ print(f"Updated layout & performance options in {res_l['config_path']}")
845
+ did_non_interactive = True
846
+
847
+ if args.sync_root:
848
+ res_root = sync_root_config(theme=chosen_theme)
849
+ print(f"Synced root prompt config ({res_root['theme']}) -> {res_root['root_config_path']}")
850
+ did_non_interactive = True
851
+
852
+ if args.sync_ecosystem:
853
+ res_eco = sync_ecosystem(theme=chosen_theme)
854
+ print(
855
+ f"Synced ecosystem ({res_eco['theme']}) -> "
856
+ f"{res_eco['env_script']}, {res_eco['tmux_conf']} & {res_eco['wezterm_lua']}"
857
+ )
858
+ did_non_interactive = True
859
+
860
+ if args.sync_greeter or args.greeter_monitors is not None or args.hide_swap:
861
+ mons = (
862
+ [tok.strip() for tok in args.greeter_monitors.replace(",", " ").split() if tok.strip()]
863
+ if args.greeter_monitors is not None
864
+ else None
865
+ )
866
+ res_g = sync_greeter_theme(
867
+ theme=chosen_theme,
868
+ monitors=mons,
869
+ hide_swap_if_unavailable=args.hide_swap,
870
+ )
871
+ print(f"Synced greeter config ({res_g['theme']}) -> {res_g['config_path']}")
872
+ did_non_interactive = True
873
+
874
+ if did_non_interactive:
875
+ return 0
876
+
877
+ run_theme_tui(
878
+ themes,
879
+ clear_screen_enabled=not args.no_clear,
880
+ force_white=args.force_white_text,
881
+ keep_input=args.keep_input,
882
+ )
883
+ return 0
884
+
885
+
886
+ if __name__ == "__main__":
887
+ raise SystemExit(main())