diff --git a/include/ghostty.h b/include/ghostty.h index 1a0a7c9c6..826e919af 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -309,6 +309,7 @@ typedef struct { void *nsview; double scale_factor; uint16_t font_size; + const char *working_directory; } ghostty_surface_config_s; typedef void (*ghostty_runtime_wakeup_cb)(void *); diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index da5a60273..a4cf66074 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -208,6 +208,9 @@ pub const Surface = struct { /// The font size to inherit. If 0, default font size will be used. font_size: u16 = 0, + + /// The working directory to load into. + working_directory: [*:0]const u8 = "", }; pub fn init(self: *Surface, app: *App, opts: Options) !void { @@ -236,6 +239,11 @@ pub const Surface = struct { var config = try apprt.surface.newConfig(app.core_app, app.config); defer config.deinit(); + // If we have a working directory from the options then we set it. + // TODO: validate the working directory + const wd = std.mem.sliceTo(opts.working_directory, 0); + if (wd.len > 0) config.@"working-directory" = wd; + // Initialize our surface right away. We're given a view that is // ready to use. try self.core_surface.init(