thag_rs 0.2.0

A versatile cross-platform playground and REPL for Rust snippets, expressions and programs. Accepts a script file or dynamic options.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
## Running the built-in tools

`thag_rs` includes several built-in tools that are compiled as separate binaries. These tools are available after installing `thag_rs` with the `tools` feature enabled, or you can install them individually. Some of them require `thag` itself to be installed.

### Installing the tools

```bash
# Install all tools
cargo install thag_rs --features tools

# Or install tools individually, for example:
cargo install thag_rs --features tools --bin thag_copy
cargo install thag_rs --features tools --bin thag_paste
cargo install thag_rs --features tools --bin thag_legible
```

### Basic usage

Each tool can be run directly by name:

```bash
thag_convert_themes --help
thag_clippy
thag_gen_readme
# ... etc
```

### Getting help

Most tools support `--help` or `-h` for usage information:

```bash
thag_convert_themes --help
thag_clippy --help
```

### Tool categories

The tools are organized into several categories:

- **Development tools**: Code analysis, formatting, and development utilities
- **Theme tools**: Theme conversion and management utilities
- **Documentation tools**: README generation and documentation utilities
- **Analysis tools**: AST analysis, profiling, and debugging tools
- **Utility tools**: General-purpose utilities and helpers

### Building from source

If you're building from source, you can build all tools with:

```bash
cargo build --features tools
```

Or build individual tools:

```bash
cargo build --bin thag_convert_themes --features tools
```

### Integration with thag

Many of these tools integrate with the main `thag` command and can be used as part of your Rust scripting workflow.

***
## Detailed script listing

### Script: thag_alacritty_add_theme.rs

**Description:**  Install generated themes for Alacritty terminal emulator

 This tool installs Alacritty themes into Alacritty's configuration directory
 and updates the Alacritty configuration file with appropriate import statements.
 The themes will typically have been created by `thag_gen_terminal_themes.rs`.
 Get Alacritty configuration directories and files
 Select themes to install using file navigator
 Find theme files in a directory
 Update Alacritty configuration with theme imports
 Update configuration file with specific theme
 Show manual configuration instructions
 Show installation summary
 Show verification steps

**Purpose:** Install and configure thag themes for Alacritty terminal

**Crates:** `dirs`, `inquire`, `thag_proc_macros`, `thag_styling`, `toml_edit`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools

**Link:** [thag_alacritty_add_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_alacritty_add_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_alacritty_add_theme.rs
```

---

### Script: thag_ast.rs

**Description:**  Tries to convert input to a `syn` abstract syntax tree (`syn::File` or `syn::Expr`).

**Purpose:** Debugging

**Crates:** `quote`, `syn`, `thag_common`

**Type:** Program

**Categories:** AST, crates, technique, tools

**Link:** [thag_ast.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_ast.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_ast.rs
```

---

### Script: thag_cargo.rs

**Description:**  `thag` prompted front-end command to run Cargo commands on scripts.

 Prompts the user to select a Rust script and a cargo command to run against the
 script's generated project, and invokes `thag` with the --cargo option to run it.

**Purpose:** A user-friendly interface to the `thag` `--cargo` option.

**Crates:** `atty`, `inquire`, `thag_common`, `thag_proc_macros`, `thag_rs`

**Type:** Program

**Categories:** technique, thag_front_ends, tools

**Link:** [thag_cargo.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_cargo.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_cargo.rs
```

---

### Script: thag_clippy.rs

**Description:**  `thag` prompted front-end command to run `clippy` on scripts.

 Prompts the user to select a Rust script and one or more Clippy lints to run against the
 script's generated project, and invokes `thag` with the --cargo option to run it.

**Purpose:** A user-friendly interface to the `thag` `--cargo` option specifically for running `cargo clippy` on a script.

**Crates:** `atty`, `inquire`, `thag_styling`

**Type:** Program

**Categories:** technique, thag_front_ends, tools

**Link:** [thag_clippy.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_clippy.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_clippy.rs
```

---

### Script: thag_convert_themes.rs

**Description:**  Converts `base16` and `base24` themes to `thag` `toml` format. Tested on `tinted-theming` crate to date.

 ## Usage examples:

 ### Convert a single theme

 ```Rust
 thag_convert_themes -i themes/wezterm/atelier_seaside_light.yaml -o themes/converted
 ```

 ### Convert a directory of themes (verbosely)

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -v
 ```

 ### Convert and also generate 256-color versions (verbosely)

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -c -v
 ```

 ### Force overwrite existing themes

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -f
 ```


**Purpose:** Theme generation.

**Crates:** `clap`, `serde`, `serde_yaml_ok`, `thag_styling`, `toml`

**Type:** Program

**Categories:** tools

**Link:** [thag_convert_themes.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_convert_themes.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_convert_themes.rs
```

---

### Script: thag_convert_themes_alt.rs

**Description:**  Converts `base16` and `base24` themes to `thag` `toml` format. Tested on `tinted-theming` crate to date.

 Alternative version with headings assigned according to prominence.

 ## Usage examples:

 ### Convert a single theme

 ```Rust
 thag_convert_themes -i themes/wezterm/atelier_seaside_light.yaml -o themes/converted
 ```

 ### Convert a directory of themes (verbosely)

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -v
 ```

 ### Convert and also generate 256-color versions (verbosely)

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -c -v
 ```

 ### Force overwrite existing themes

 ```Rust
 thag_convert_themes -i themes/wezterm -o themes/converted -f
 ```


**Purpose:** Theme generation.

**Crates:** `clap`, `serde`, `serde_yaml_ok`, `thag_styling`, `toml`

**Type:** Program

**Categories:** tools

**Link:** [thag_convert_themes_alt.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_convert_themes_alt.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_convert_themes_alt.rs
```

---

### Script: thag_copy.rs

**Description:**  Copies text input from `stdin` to the system clipboard.

 A cross-platform equivalent to macOS's `pbcopy`. See also `src/bin/thag_paste.rs`.
 May not work in Linux environments owing to the X11 and Wayland requiring the copying
 app to be open when pasting from the system clipboard. See `arboard` Readme.

**Purpose:** Utility

**Crates:** `arboard`, `thag_common`

**Type:** Program

**Categories:** tools

**Link:** [thag_copy.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_copy.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_copy.rs
```

---

### Script: thag_demo_help.rs

**Description:**  Demo tool to showcase the lightweight help system.

 This tool demonstrates how to use the built-in help system for thag tools.
 It shows how help information is extracted from comments and displayed consistently.

**Purpose:** Demonstrate the lightweight help system for thag tools

**Crates:** `thag_common`

**Type:** Program

**Categories:** demo, tools

**Link:** [thag_demo_help.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_demo_help.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_demo_help.rs
```

---

### Script: thag_detect_term.rs

**Description:**  A basic tool I cobbled together that uses different crates to a) test terminal
 types on different platforms, b) determine and cross-check if a light or dark
 theme is in use and c) determine the level of colour supported reported by
 the terminal.

**Purpose:** Allow checking of terminals on platforms to be supported, also test reliability of different crates.

**Crates:** `log`, `simplelog`, `termbg`, `terminal_light`, `thag_common`

**Type:** Program

**Categories:** crates, tools

**Link:** [thag_detect_term.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_detect_term.rs)

**Not suitable to be run from a URL.**


---

### Script: thag_edit_theme.rs

**Description:**  Interactive theme editor for manual color role adjustments

 This tool allows you to interactively edit theme color assignments,
 particularly useful when automatic conversion doesn't quite match your preferences.

 A color candidate with provenance information
 Main theme editor state

**Purpose:** Edit and customize theme color role assignments interactively

**Crates:** `clap`, `inquire`, `thag_styling`, `toml`

**Type:** Program

**Categories:** color, interactive, styling, theming, tools

**Link:** [thag_edit_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_edit_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_edit_theme.rs
```

---

### Script: thag_expand.rs

**Description:**  Useful front-end for `thag --cargo <script> --expand`, which in turn uses `cargo-expand` to show the macro expansion
 of a user script. This tool provides a user-friendly interface to select the script to analyse and to view the expanded code,
 either on its own or side-by-side with the original script using a choice of diff tools.

 Available viewing options for expanded code
 Run cargo-expand on the input file and return the expanded output
 Display original and expanded code side by side
 Detect terminal width to optimize side-by-side display

**Purpose:** Display the expanded code of a user script on its own or side-by-side with the original script using a choice of diff tools.

**Crates:** `anyhow`, `atty`, `crossterm`, `inquire`, `side_by_side_diff`, `tempfile`, `thag_rs`

**Type:** Program

**Categories:** diagnosis, technique, thag_front_ends, tools

**Link:** [thag_expand.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_expand.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_expand.rs
```

---

### Script: thag_find_demos.rs

**Description:**  Select demo scripts and generate and serve HTML report.

 Strategy and grunt work thanks to `ChatGPT`.

**Purpose:** Allow user to select scripts by category.

**Crates:** `edit`, `inquire`, `thag_proc_macros`, `thag_rs`, `tokio`, `warp`

**Type:** Program

**Categories:** technique, tools

**Link:** [thag_find_demos.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_find_demos.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_find_demos.rs
```

---

### Script: thag_from_rust_script.rs

**Description:**  Converts embedded manifest format from `rust-script` to `thag`.

 E.g. `cat <path_to_rust_script_file> | thag -qq demo/thag_from_rust_script.rs | thag -s [-- [options] [args] ...]`

 Place any command-line options and/or arguments for the script at the end after a -- as shown.


**Purpose:** Convenience for any `rust-script` user who wants to try out `thag`.

**Type:** Program

**Categories:** crates, tools

**Link:** [thag_from_rust_script.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_from_rust_script.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_from_rust_script.rs
```

---

### Script: thag_gen_config.rs

**Description:**  Prompted config file builder for `thag`.

 Makes a modified copy of a user-selected `config.toml` file.

 Some fields, such as RGB values in decimal and hex, are not prompted for as they are more easily entered
 using a text editor.

**Purpose:** Handy configuration file builder.

**Crates:** `convert_case`, `dirs`, `documented`, `inquire`, `strum`, `syn`, `thag_common`, `thag_styling`, `toml`

**Type:** Program

**Categories:** crates, technique, tools

**Link:** [thag_gen_config.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_config.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_config.rs
```

---

### Script: thag_gen_errors.rs

**Description:**  Quick and easy prompted generator for new custom error types and new variants required
 by existing custom error types.

 Prompts for the new or existing custom error type, the
 new variants, any types wrapped by the new variants, and any special display messages.

 The output can be saved to a new error module in the case of a new custom error type,
 or simply copied and pasted in sections from the output into an existing error module
 in the case of an existing custom error type.

 Strategy and grunt work thanks to `ChatGPT`.

**Purpose:** Facilitate generation and enhancement of custom error modules.

**Crates:** `heck`, `inquire`, `thag_styling`

**Type:** Program

**Categories:** technique, tools

**Link:** [thag_gen_errors.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_errors.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_errors.rs
```

---

### Script: thag_gen_proc_macro_readme.rs

**Description:**  This script generates documentation for proc macros defined in `demo/proc_macros/lib.rs`
 and creates a comprehensive README.md file for the proc macros directory.

 It extracts proc macro definitions, their documentation, and links them to their
 corresponding example files in the demo/ directory.

**Purpose:** Generate README.md documentation for proc macros with examples and usage

**Crates:** `syn`, `thag_styling`

**Type:** Program

**Categories:** proc_macros, technique, tools

**Link:** [thag_gen_proc_macro_readme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_proc_macro_readme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_proc_macro_readme.rs
```

---

### Script: thag_gen_readme.rs

**Description:**  This is the script used to collect script metadata for the `demo` and `tools` directories and generate
 local `README.md` files documenting those directories.

 Strategy and grunt work thanks to `ChatGPT`.

**Purpose:** Document demo scripts in a demo/README.md as a guide for the user, and the same for tools/ scripts.

**Crates:** `heck`, `inquire`, `pathdiff`, `regex`, `strum`, `thag_proc_macros`, `thag_rs`

**Type:** Program

**Categories:** technique, tools

**Link:** [thag_gen_readme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_readme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_readme.rs
```

---

### Script: thag_gen_terminal_themes.rs

**Description:**  Export `thag_styling` themes to multiple terminal emulator formats

 This tool exports `thag_styling` theme files to the following terminal emulator formats:
 `Alacritty`, `iTerm2`, `Kitty`, `Konsole`, `Mintty`, `WezTerm` and `Windows Terminal`.
 Themes are exported to organized subdirectories in ./`exported_themes`/. It also
 optionally displays instructions for installing them into the respective emulators.
 Select theme files using file navigator
 Find all theme files in a directory
 Interactive theme browser similar to `thag_show_themes`
 Get export configuration from user
 Process a single theme file
 Show installation instructions for selected formats with actual theme names

**Purpose:** Export thag themes to multiple terminal emulator formats and display further instructions.

**Crates:** `inquire`, `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools

**Link:** [thag_gen_terminal_themes.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_terminal_themes.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_gen_terminal_themes.rs
```

---

### Script: thag_get_demo_dir.rs

**Description:**  Fast download of `thag_rs` demo directory (starter kit) with subdirectories.
 Git `sparse-checkout` approach suggested and written by `ChatGPT`, local directory handling assisted by `Claude`.

 `thag_styling` included

**Purpose:** Prototype for `thag_get_demo_dir`.

**Crates:** `inquire`, `thag_styling`

**Type:** Program

**Categories:** crates, prototype, technique, tools

**Link:** [thag_get_demo_dir.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_get_demo_dir.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_get_demo_dir.rs
```

---

### Script: thag_image_to_theme.rs

**Description:**  Generate `thag_styling` themes from image files using file navigator.

 This tool analyzes image files to extract dominant colors and generates
 `thag_styling`-compatible theme files. Supports auto-detection of theme type
 (light/dark) and customizable color extraction parameters.
 Get theme configuration from user input
 Display comprehensive theme information
 Display color palette with visual preview
 Extract RGB information from a style for display
 Save theme to a TOML file using file navigator

**Purpose:** Generate custom `thag_styling` themes from images

**Crates:** `inquire`, `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools

**Link:** [thag_image_to_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_image_to_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_image_to_theme.rs
```

---

### Script: thag_legible.rs

**Description:**  Unescape \n and \\" markers in a string to convert the wall of text to readable lines.
 This is trickier than it seems because in a compile-time literal, \n compiles to the
 true line feed character 10 (x0A), whereas a \n generated or captured as a literal
 at run time is encoded as ('\', 'n'() = (92, 110) = 0x5c6e. Not surprisingly, the two
 representations, while they look identical to the programmer, don't always behave
 the same.

 See `demo/dethagomizer.rs` for a Regex version.

**Purpose:** Useful script for converting a wall of text such as some TOML errors back into legible formatted messages.

**Crates:** `thag_common`

**Type:** Program

**Categories:** crates, technique, tools

**Link:** [thag_legible.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_legible.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_legible.rs
```

---

### Script: thag_markdown.rs

**Description:**  Quick markdown viewer checks your markdown for GitHub compatibility.

 Script generated by GitHub Copilot.

 Uses the GitHub REST API endpoint `/markdown` to convert Markdown to HTML and serves the HTML using the `warp` web framework. Make sure your Markdown file is less than 400 KB, as per the API's limitations.

 ### Instructions:

 1. Set the `GITHUB_TOKEN` environment variable with your GitHub token (classic or fine-grained).

 2. Run the script:

    ```bash
    thag_markdown <path_to_markdown_file>
    ```

 3. Open `http://localhost:8080` in your browser to view the rendered HTML.

**Purpose:** Useful tool and demo.

**Crates:** `reqwest`, `serde_json`, `thag_common`, `tokio`, `warp`

**Type:** Program

**Categories:** demo, tools

**Link:** [thag_markdown.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_markdown.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_markdown.rs
```

---

### Script: thag_migrate_tool.rs

**Description:**  Tool to help migrate existing tools from tools/ to src/bin/ with auto-help integration.

 This utility helps migrate tools by:
 - Moving files from tools/ to src/bin/
 - Adding the `auto_help!` macro integration
 - Updating Cargo.toml entries if needed
 - Preserving all existing functionality

**Purpose:** Migrate tools from tools/ directory to src/bin/ with auto-help integration

**Crates:** `inquire`, `thag_styling`

**Type:** Program

**Categories:** tools

**Link:** [thag_migrate_tool.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_migrate_tool.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_migrate_tool.rs
```

---

### Script: thag_mintty_add_theme.rs

**Description:**  Mintty theme installer for Git Bash on Windows

 This Windows-only tool installs thag themes into Mintty by copying theme files
 to the Mintty themes directory and optionally updating the ~/.minttyrc configuration.
 Supports selecting individual themes or entire directories of themes.
 Check if we have write permission to a directory
 Select themes to install using file navigator
 Find mintty theme files in a directory (files with no extension)
 Check if a file appears to be a mintty theme file
 Copy a mintty theme file to the themes directory

**Purpose:** Install thag themes for Mintty (Git Bash)

**Crates:** `dirs`, `inquire`, `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools, windows

**Link:** [thag_mintty_add_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_mintty_add_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_mintty_add_theme.rs
```

---

### Script: thag_palette.rs

**Description:**  Terminal Palette Display Tool

 This tool displays the current terminal's color palette, including:
 - All 16 ANSI colors (0-15)
 - Extended 256-color palette samples
 - True color capability test
 - Terminal background detection
 - Current thag theme colors for comparison
 Display basic terminal information
 Display the 16 basic ANSI colors
 Display a row of colors with their indices and names
 Display samples from the 256-color palette
 Test true color capability with a gradient
 Display current thag theme colors
 Extract RGB information from a style for display

**Purpose:** Show terminal palette colors

**Crates:** `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools

**Link:** [thag_palette.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_palette.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_palette.rs
```

---

### Script: thag_palette_vs_theme.rs

**Description:**  Terminal palette comparison tool with theme selection

 This tool displays the current terminal's color palette alongside
 a selected thag theme for direct comparison. Helps identify color
 mapping issues and verify theme installation.
 RGB color representation
 Error types for palette querying
 Cached palette query results
 Production-ready palette color query using crossterm threading

 # Errors

 Will bubble up any terminal errors encountered.
 Parse OSC 4 response from accumulated buffer
 Parse hex component (2 or 4 digits)
 Get terminal identifier for caching
 Production-ready palette detection with caching
 Select a theme using file navigator or built-in themes
 Display basic terminal information
 Attempt to detect terminal emulator
 Display the 16 basic ANSI colors
 Display a row of colors with their indices and names
 Display theme colors with visual preview
 Display recommendations based on comparison
 Detect potential issues with theme/terminal compatibility
 Calculate contrast ratio between two RGB colors
 Extract RGB information from a style for display
 Brighten a color by increasing its components

**Purpose:** Compare terminal palette with thag theme colors

**Crates:** `char`, `crossterm`, `inquire`, `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools

**Link:** [thag_palette_vs_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_palette_vs_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_palette_vs_theme.rs
```

---

### Script: thag_paste.rs

**Description:**  Writes text from the system clipboard to `stdout`.

 A cross-platform equivalent to macOS's `pbpaste`. See also `src/bin/thag_copy.rs`.
 May not work with `pbcopy` in Linux environments owing to the X11 and Wayland requiring the copying
 app to be open when pasting from the system clipboard. See `arboard` Readme.

**Purpose:** Utility

**Crates:** `arboard`, `thag_common`

**Type:** Program

**Categories:** tools

**Link:** [thag_paste.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_paste.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_paste.rs
```

---

### Script: thag_prompt.rs

**Description:**  Basic prompted front-end to build and run a `thag` command.
 Copy text to clipboard using arboard (cross-platform)
 Expand environment variables in a string (e.g., $PWD, ${HOME})

**Purpose:** Simplify running `thag`.

**Crates:** `arboard`, `clap`, `inquire`, `regex`, `thag_rs`, `thag_styling`

**Type:** Program

**Categories:** cli, interactive, thag_front_ends, tools

**Link:** [thag_prompt.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_prompt.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_prompt.rs
```

---

### Script: thag_rs.rs

**Description:**
**Purpose:**

**Crates:** `thag_profiler`, `thag_rs`, `thag_styling`

**Type:** Program

**Categories:** missing

**Link:** [thag_rs.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_rs.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_rs.rs
```

---

### Script: thag_show_themes.rs

**Description:**  Display built-in themes and their styling with terminal setup instructions

 This tool helps you explore the available built-in themes and provides
 terminal setup instructions for optimal display.

**Purpose:** Help get best use out of styling with built-in themes.

**Crates:** `inquire`, `thag_styling`

**Type:** Program

**Categories:** reference, technique, tools

**Link:** [thag_show_themes.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_show_themes.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_show_themes.rs
```

---

### Script: thag_sync_palette.rs

**Description:**  Terminal palette synchronization using OSC sequences,

 This binary provides command-line access to `thag_styling`'s palette synchronization
 functionality, allowing you to apply theme colors directly to your terminal's palette for convenience.

 Note that it does not support `KDE Konsole` or `Mintty` terminal types because they do not support
 the required OSC 4 ANSI escape sequences.

**Purpose:** Try out custom terminal themes or apply them dynamically, including for a session if incorporated in a terminal profile file.

**Crates:** `thag_styling`

**Type:** Program

**Categories:** ansi, color, customization, interactive, styling, terminal, theming, tools, windows, xterm

**Link:** [thag_sync_palette.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_sync_palette.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_sync_palette.rs
```

---

### Script: thag_theme.rs

**Description:**  Displays the current theme palette and attributes.

 E.g. `thag_theme` or `thag src/bin/thag_theme.rs`

**Purpose:** Show current theme.

**Crates:** `thag_styling`

**Type:** Program

**Categories:** ansi, color, styling, terminal, theming, tools, xterm

**Link:** [thag_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_theme.rs
```

---

### Script: thag_to_rust_script.rs

**Description:**  Converts embedded manifest format from `thag` to `rust-script`.

**Purpose:** Convenience for any `thag` user who wants to try out `rust-script`.

**Crates:** `thag_rs`

**Type:** Program

**Categories:** crates, tools

**Link:** [thag_to_rust_script.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_to_rust_script.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_to_rust_script.rs
```

---

### Script: thag_url.rs

**Description:**  `thag` front-end command to run Rust scripts from URLs provided that `thag` can figure out the dependencies.

 It supports raw files as well as GitHub, GitLab, Bitbucket and the Rust Playground.

 This relies on `thag`'s dependency inference to resolve dependencies and even features (since default
 features for a given crate can be configured via `thag -C`). Failing that, you can of course paste the raw
 source into the thag playground (`thag -d`) and edit / run / save it there, or directly into a `.rs` file
 and run it with `thag /path/to/file`.

 Usage:

 ```bash
 thag_url <url> [additional_thag_args] [-- <script_args>]
 ```

 Example:

 ```bash
 thag_url https://github.com/clap-rs/clap/blob/master/examples/demo.rs -- --name "is this the Krusty Krab?"
 ```

 Extracts the syn AST expression for a Rust code section.

 # Errors

 This function will bubble up any `syn` parse errors encountered.

**Purpose:** A front-end to allow `thag` to run scripts from URLs while keeping `thag` itself free of network dependencies.

**Crates:** `syn`, `tempfile`, `thag_common`, `tinyget`, `url`

**Type:** Program

**Categories:** technique, thag_front_ends, tools

**Link:** [thag_url.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_url.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_url.rs
```

---

### Script: thag_winterm_add_theme.rs

**Description:**  Windows Terminal theme installer with file navigator

 This Windows-only tool installs thag themes into Windows Terminal by
 adding theme schemes to the settings.json configuration file. Supports
 selecting individual themes or entire directories of themes.

**Purpose:** Install thag themes for Windows Terminal

**Crates:** `dirs`, `inquire`, `serde_json`, `thag_styling`

**Type:** Program

**Categories:** color, styling, terminal, theming, tools, windows

**Link:** [thag_winterm_add_theme.rs](https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_winterm_add_theme.rs)

**Run this example:**

```bash
thag_url https://github.com/durbanlegend/thag_rs/blob/main/src/bin/thag_winterm_add_theme.rs
```

---