diff --git a/src/config/Config.zig b/src/config/Config.zig index 16b465168..2891e24e9 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -411,6 +411,9 @@ keybind: Keybinds = .{}, /// Debug builds of Ghostty have a separate single-instance ID. @"gtk-single-instance": bool = true, +/// This will be used to set the TERM environment variable +term: []const u8 = "ghostty", + /// This is set by the CLI parser for deinit. _arena: ?ArenaAllocator = null, @@ -899,6 +902,11 @@ pub fn finalize(self: *Config) !void { } } + // Prevent setting TERM to an empty string + if (self.term.len == 0) { + self.term = "ghostty"; + } + // The default for the working directory depends on the system. const wd = self.@"working-directory" orelse switch (builtin.os.tag) { .macos => if (c.getppid() == 1) "home" else "inherit", diff --git a/src/terminfo/ghostty.zig b/src/terminfo/ghostty.zig index 42dd2fea7..5c78a6eb1 100644 --- a/src/terminfo/ghostty.zig +++ b/src/terminfo/ghostty.zig @@ -98,6 +98,12 @@ pub const ghostty: Source = .{ // Colored underlines .{ .name = "Setulc", .value = .{ .string = "\\E[58:2::%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%d%;m" } }, + // Cursor styles + .{ .name = "Ss", .value = .{ .string = "\\E[%p1%d q" } }, + + // Cursor style reset + .{ .name = "Se", .value = .{ .string = "\\E[2 q" } }, + // These are all capabilities that should be pretty straightforward // and map to input sequences. .{ .name = "bel", .value = .{ .string = "^G" } }, diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 974c1de1b..654dfae0b 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -91,6 +91,7 @@ pub const DerivedConfig = struct { foreground: configpkg.Config.Color, background: configpkg.Config.Color, osc_color_report_format: configpkg.Config.OSCColorReportFormat, + term: []const u8, pub fn init( alloc_gpa: Allocator, @@ -106,6 +107,7 @@ pub const DerivedConfig = struct { .foreground = config.foreground, .background = config.background, .osc_color_report_format = config.@"osc-color-report-format", + .term = config.term, }; } @@ -663,7 +665,7 @@ const Subprocess = struct { if (opts.resources_dir) |base| { var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; const dir = try std.fmt.bufPrint(&buf, "{s}/terminfo", .{base}); - try env.put("TERM", "xterm-ghostty"); + try env.put("TERM", opts.config.term); try env.put("COLORTERM", "truecolor"); try env.put("TERMINFO", dir); } else {