Skip to content

Commit 2739863

Browse files
committed
Support --show-env option in terminal-autodetect
1 parent c5083df commit 2739863

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Revision history for Terminal-Capabilities
22

33
{{$NEXT}}
4+
[Features]
5+
- Support --show-env option in `terminal-autodetect` to show values of all
6+
known terminal-related environment variables
7+
48

59
0.0.4 2025-05-30T20:53:23-07:00
610
[Features]
@@ -13,6 +17,7 @@ Revision history for Terminal-Capabilities
1317
- Document ::Autodetect module use in README
1418
- Various bits of README cleanup and clarification
1519

20+
1621
0.0.3 2023-12-29T19:39:04-08:00
1722
- Update test missed in WGL4R support changes
1823

bin/terminal-autodetect

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
11
#!/usr/bin/env raku
22
use Terminal::Capabilities::Autodetect;
33

4-
my ($caps, $terminal, $version) = terminal-env-detect;
5-
put "Terminal: {$terminal // 'unknown'}";
6-
put "Version: {$version // 'unknown'}";
7-
put 'Caps:';
8-
9-
for < symbol-set vt100-boxes bold italic inverse underline
10-
color3bit colorbright color8bit color24bit
11-
emoji-text emoji-color emoji-skin
12-
emoji-iso emoji-reg emoji-zwj > {
13-
printf " %-11s %s\n", $_, $caps."$_"();
4+
constant BOLD_YELLOW = "\e[1;33m";
5+
constant RESET = "\e[0m";
6+
7+
# Display a section of detected environment variables
8+
sub section($section, @vars) {
9+
put BOLD_YELLOW ~ $section ~ RESET;
10+
printf("%-22s %s\n", $_, %*ENV{$_} // '') for @vars;
11+
put '';
12+
}
13+
14+
15+
# Show current values of all known terminal-related environment variables
16+
sub show-env() {
17+
section('General', < LANG TERM COLORTERM COLORFGBG >);
18+
section('Alacritty', < ALACRITTY_WINDOW_ID ALACRITTY_LOG ALACRITTY_SOCKET >);
19+
section('CRT', < COLORSCHEMES_DIR KB_LAYOUT_DIR >);
20+
section('kitty', < KITTY_WINDOW_ID KITTY_PID KITTY_PUBLIC_KEY KITTY_INSTALLATION_DIR >);
21+
section('Konsole', < KONSOLE_DBUS_SERVICE KONSOLE_DBUS_SESSION KONSOLE_DBUS_WINDOW >);
22+
section('Misc', < TERM_PROGRAM TERM_PROGRAM_VERSION >);
23+
section('MLTerm', [ 'MLTERM', ]);
24+
section('Qt', < D_DISABLE_RT_SCREEN_SCALE QT_SCALE_FACTOR_ROUNDING_POLICY >);
25+
section('Terminator', < TERMINATOR_DBUS_NAME TERMINATOR_DBUS_PATH TERMINATOR_UUID >);
26+
section('Terminology', < TERMINOLOGY XTERM_256_COLORS >);
27+
section('Zutty', [ 'ZUTTY_VERSION', ]);
28+
section('VTE', < VTE_VERSION TILIX_ID GNOME_TERMINAL_SERVICE GNOME_TERMINAL_SCREEN >);
29+
section('Xterm', < XTERM_VERSION XTERM_SHELL XTERM_LOCALE >);
30+
}
31+
32+
33+
#| Show autodetected terminal capabilities
34+
sub MAIN(Bool :$show-env, #= Show known terminal-related environment values also
35+
) {
36+
if $show-env {
37+
show-env;
38+
put BOLD_YELLOW ~ 'Detected' ~ RESET;
39+
}
40+
41+
my ($caps, $terminal, $version) = terminal-env-detect;
42+
put "Terminal: {$terminal // 'unknown'}";
43+
put "Version: {$version // 'unknown'}";
44+
put 'Caps:';
45+
46+
for < symbol-set vt100-boxes bold italic inverse underline
47+
color3bit colorbright color8bit color24bit
48+
emoji-text emoji-color emoji-skin
49+
emoji-iso emoji-reg emoji-zwj > {
50+
printf " %-11s %s\n", $_, $caps."$_"();
51+
}
1452
}

0 commit comments

Comments
 (0)