mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 21:40:29 +00:00
macos: include ghostty subdirectory under Resources
This enables us to treat Ghostty's resources directory the same way whether it is installed in a macOS app bundle or under e.g. /usr/share.
This commit is contained in:
committed by
Mitchell Hashimoto
parent
8751502878
commit
18f2fb3fbd
@@ -36,7 +36,7 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
|
||||
// On MacOS, we look for the app bundle path.
|
||||
if (comptime builtin.target.isDarwin()) {
|
||||
if (try maybeDir(&dir_buf, dir, "Contents/Resources", sentinel)) |v| {
|
||||
return try alloc.dupe(u8, v);
|
||||
return try std.fs.path.join(alloc, &.{ v, "ghostty" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ pub fn resourcesDir(alloc: std.mem.Allocator) !?[]const u8 {
|
||||
// is valid even on Mac since there is nothing that requires
|
||||
// Ghostty to be in an app bundle.
|
||||
if (try maybeDir(&dir_buf, dir, "share", sentinel)) |v| {
|
||||
// When found under a "share" prefix, the resources directory is the
|
||||
// "ghostty" subdirectory.
|
||||
return try std.fs.path.join(alloc, &.{ v, "ghostty" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,25 +762,13 @@ const Subprocess = struct {
|
||||
try env.put("TERM", opts.config.term);
|
||||
try env.put("COLORTERM", "truecolor");
|
||||
|
||||
// Assume that the resources directory is adjacent to the terminfo
|
||||
// database
|
||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||
const terminfo_dir = terminfo_dir: {
|
||||
// On macOS the terminfo directory can be inside the resources
|
||||
// directory, so check if that is the case
|
||||
if (comptime builtin.target.isDarwin()) {
|
||||
if (try internal_os.maybeDir(&buf, base, "terminfo", "ghostty.termcap")) |v| {
|
||||
break :terminfo_dir v;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise we assume the terminfo directory is adjacent to the
|
||||
// resources directory
|
||||
const parent = std.fs.path.basename(base);
|
||||
break :terminfo_dir try internal_os.maybeDir(&buf, parent, "terminfo", "ghostty.termcap");
|
||||
};
|
||||
|
||||
if (terminfo_dir) |dir| {
|
||||
try env.put("TERMINFO", dir);
|
||||
}
|
||||
const dir = try std.fmt.bufPrint(&buf, "{s}/terminfo", .{
|
||||
std.fs.path.dirname(base) orelse unreachable,
|
||||
});
|
||||
try env.put("TERMINFO", dir);
|
||||
} else {
|
||||
if (comptime builtin.target.isDarwin()) {
|
||||
log.warn("ghostty terminfo not found, using xterm-256color", .{});
|
||||
|
||||
Reference in New Issue
Block a user