Skip to content

Commit 962f1a3

Browse files
committed
Add autodetection for Ghostty and tmux
1 parent 99e678d commit 962f1a3

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

Changes

Lines changed: 4 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+
- Add autodetection support for Ghostty
6+
- Add initial autodection support for tmux (but not yet the underlying terminal)
7+
48

59
0.0.5 2025-10-05T19:57:11-07:00
610
[Features]

bin/terminal-autodetect

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ sub section($section, @vars) {
1414

1515
# Show current values of all known terminal-related environment variables
1616
sub show-env() {
17-
section('General', < LANG TERM COLORTERM COLORFGBG >);
17+
section('General', < LANG TERM COLORTERM COLORFGBG TERM_PROGRAM TERM_PROGRAM_VERSION >);
1818
section('Alacritty', < ALACRITTY_WINDOW_ID ALACRITTY_LOG ALACRITTY_SOCKET >);
1919
section('CRT', < COLORSCHEMES_DIR KB_LAYOUT_DIR >);
20+
section('Ghostty', < GHOSTTY_BIN_DIR GHOSTTY_RESOURCES_DIR GHOSTTY_SHELL_INTEGRATION_NO_SUDO >);
2021
section('kitty', < KITTY_WINDOW_ID KITTY_PID KITTY_PUBLIC_KEY KITTY_INSTALLATION_DIR >);
2122
section('Konsole', < KONSOLE_DBUS_SERVICE KONSOLE_DBUS_SESSION KONSOLE_DBUS_WINDOW >);
22-
section('Misc', < TERM_PROGRAM TERM_PROGRAM_VERSION >);
2323
section('MLTerm', [ 'MLTERM', ]);
2424
section('Qt', < D_DISABLE_RT_SCREEN_SCALE QT_SCALE_FACTOR_ROUNDING_POLICY >);
2525
section('Terminator', < TERMINATOR_DBUS_NAME TERMINATOR_DBUS_PATH TERMINATOR_UUID >);
2626
section('Terminology', < TERMINOLOGY XTERM_256_COLORS >);
27+
section('tmux', < TMUX TMUX_PANE >);
2728
section('Zutty', [ 'ZUTTY_VERSION', ]);
2829
section('VTE', < VTE_VERSION TILIX_ID GNOME_TERMINAL_SERVICE GNOME_TERMINAL_SCREEN >);
2930
section('Xterm', < XTERM_VERSION XTERM_SHELL XTERM_LOCALE >);

lib/Terminal/Capabilities/Autodetect.rakumod

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ sub terminal-env-detect() is export {
8787
$color8bit = True;
8888
$emoji-text = True;
8989
}
90+
elsif $prog eq 'ghostty' {
91+
# Ghostty sets COLORTERM=truecolor, detected above
92+
93+
$italic = True;
94+
$emoji-text = True;
95+
$emoji-color = True;
96+
$emoji-skin = True;
97+
$emoji-iso = True;
98+
$emoji-reg = True;
99+
$emoji-zwj = True;
100+
}
90101
elsif $prog eq 'iTerm.app' {
91102
$italic = True;
92103
$color8bit = True;
@@ -162,6 +173,22 @@ sub terminal-env-detect() is export {
162173
$colorbright = True;
163174
$color8bit = True;
164175
}
176+
elsif ?$term.starts-with('tmux') {
177+
$terminal = 'tmux';
178+
$version = %*ENV<TERM_PROGRAM_VERSION>;
179+
180+
# XXXX: Limited by symbol-set of underlying terminal emulator too
181+
$symbol-set = symbol-set('Full') if $has-utf8;
182+
183+
# XXXX: Detection of underlying terminal emulator to AND with these?
184+
$italic = True;
185+
$emoji-text = True;
186+
$emoji-color = True;
187+
$emoji-skin = True;
188+
$emoji-iso = True;
189+
$emoji-reg = False;
190+
$emoji-zwj = False;
191+
}
165192
elsif ?$term.starts-with('screen'|'vt220'|'vt420')
166193
|| ?$term.lc.contains('color'|'ansi'|'cygwin'|'linux') {
167194
$terminal = $term;

0 commit comments

Comments
 (0)