ghostty/src/config/edit.zig
Borja Clemente a1fd9f733c Remove log from imports as it is unused
Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-19 09:23:30 +01:00

25 lines
769 B
Zig

const std = @import("std");
const Allocator = std.mem.Allocator;
const internal_os = @import("../os/main.zig");
/// Open the configuration in the OS default editor according to the default
/// paths the main config file could be in.
pub fn open(alloc_gpa: Allocator) !void {
// default location
const config_path = try internal_os.xdg.config(alloc_gpa, .{ .subdir = "ghostty/config" });
defer alloc_gpa.free(config_path);
// Try to create file and go on if it already exists
_ = std.fs.createFileAbsolute(
config_path,
.{ .exclusive = true },
) catch |err| {
switch (err) {
error.PathAlreadyExists => {},
else => return err,
}
};
try internal_os.open(alloc_gpa, config_path);
}