From dfe21dcac41d61ca80a8d76262cd77a4c1236e49 Mon Sep 17 00:00:00 2001 From: cryptocode Date: Mon, 28 Aug 2023 20:04:43 +0200 Subject: [PATCH] Set TERM_PROGRAM and TERM_PROGRAM_VERSION environment variables. WezTerm claims this is an emerging de-facto standard for terminal emulator identification: https://github.com/wez/wezterm/blob/a103b6d97adcc439e27cec0d3bb2c0f72a79095d/config/src/config.rs#L1526-L1529 One example of usage in the wild is neovim doing capability detection: https://github.com/neovim/neovim/blob/f050aaabbb31b58ebac519a6f7014610f2b119f0/src/nvim/tui/tui.c#L206-L211 Ghostty now reports this: $echo $TERM_PROGRAM ghostty $echo $TERM_PROGRAM_VERSION 0.1.0-main+aa08f3c I think it's really nice that the commit hash is included, as users can provide this in issue reports. WezTerm does the same. I use these variables in my tui library in addition to $TERM and $COLORTERM for capability detection, which is what motivated this PR. --- src/termio/Exec.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 35a74c837..b7cd5579a 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -612,6 +612,9 @@ const Subprocess = struct { try env.put("COLORTERM", "truecolor"); } + try env.put("TERM_PROGRAM", "ghostty"); + try env.put("TERM_PROGRAM_VERSION", build_config.version_string); + // When embedding in macOS and running via XCode, XCode injects // a bunch of things that break our shell process. We remove those. if (comptime builtin.target.isDarwin() and build_config.artifact == .lib) {