mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
config: add term config option
Add a configuration key for the TERM environment variable. Default this to "ghostty". Most TEs are using their name as the default TERM value. Most modern termulators aren't even providing "xterm-" as an alias anymore, after some drama between kitty / ncurses. Notably, this also has issues for tcell-based applications (I've submitted a PR to tcell to fix) because it fails if the TERM value doesn't match the _primary_ name of the terminal in the terminfo file. Providing a config option allows users to modify-with-persistence if they have issues, but Ghostty should be known as Ghostty by default!
This commit is contained in:
@ -411,6 +411,9 @@ keybind: Keybinds = .{},
|
|||||||
/// Debug builds of Ghostty have a separate single-instance ID.
|
/// Debug builds of Ghostty have a separate single-instance ID.
|
||||||
@"gtk-single-instance": bool = true,
|
@"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.
|
/// This is set by the CLI parser for deinit.
|
||||||
_arena: ?ArenaAllocator = null,
|
_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.
|
// The default for the working directory depends on the system.
|
||||||
const wd = self.@"working-directory" orelse switch (builtin.os.tag) {
|
const wd = self.@"working-directory" orelse switch (builtin.os.tag) {
|
||||||
.macos => if (c.getppid() == 1) "home" else "inherit",
|
.macos => if (c.getppid() == 1) "home" else "inherit",
|
||||||
|
@ -91,6 +91,7 @@ pub const DerivedConfig = struct {
|
|||||||
foreground: configpkg.Config.Color,
|
foreground: configpkg.Config.Color,
|
||||||
background: configpkg.Config.Color,
|
background: configpkg.Config.Color,
|
||||||
osc_color_report_format: configpkg.Config.OSCColorReportFormat,
|
osc_color_report_format: configpkg.Config.OSCColorReportFormat,
|
||||||
|
term: []const u8,
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
alloc_gpa: Allocator,
|
alloc_gpa: Allocator,
|
||||||
@ -106,6 +107,7 @@ pub const DerivedConfig = struct {
|
|||||||
.foreground = config.foreground,
|
.foreground = config.foreground,
|
||||||
.background = config.background,
|
.background = config.background,
|
||||||
.osc_color_report_format = config.@"osc-color-report-format",
|
.osc_color_report_format = config.@"osc-color-report-format",
|
||||||
|
.term = config.term,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +665,7 @@ const Subprocess = struct {
|
|||||||
if (opts.resources_dir) |base| {
|
if (opts.resources_dir) |base| {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
const dir = try std.fmt.bufPrint(&buf, "{s}/terminfo", .{base});
|
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("COLORTERM", "truecolor");
|
||||||
try env.put("TERMINFO", dir);
|
try env.put("TERMINFO", dir);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user