mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-28 22:18:36 +00:00
macos: when executing a script directly, always wait after command
This commit is contained in:
@@ -419,6 +419,7 @@ typedef struct {
|
|||||||
ghostty_env_var_s* env_vars;
|
ghostty_env_var_s* env_vars;
|
||||||
size_t env_var_count;
|
size_t env_var_count;
|
||||||
const char* initial_input;
|
const char* initial_input;
|
||||||
|
bool wait_after_command;
|
||||||
} ghostty_surface_config_s;
|
} ghostty_surface_config_s;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@@ -413,6 +413,11 @@ class AppDelegate: NSObject,
|
|||||||
// `<filename>; exit` which is what Terminal and iTerm2 do.
|
// `<filename>; exit` which is what Terminal and iTerm2 do.
|
||||||
config.initialInput = "\(filename); exit\n"
|
config.initialInput = "\(filename); exit\n"
|
||||||
|
|
||||||
|
// For commands executed directly, we want to ensure we wait after exit
|
||||||
|
// because in most cases scripts don't block on exit and we don't want
|
||||||
|
// the window to just flash closed once complete.
|
||||||
|
config.waitAfterCommand = true
|
||||||
|
|
||||||
// Set the parent directory to our working directory so that relative
|
// Set the parent directory to our working directory so that relative
|
||||||
// paths in scripts work.
|
// paths in scripts work.
|
||||||
config.workingDirectory = (filename as NSString).deletingLastPathComponent
|
config.workingDirectory = (filename as NSString).deletingLastPathComponent
|
||||||
|
@@ -425,6 +425,9 @@ extension Ghostty {
|
|||||||
/// Extra input to send as stdin
|
/// Extra input to send as stdin
|
||||||
var initialInput: String? = nil
|
var initialInput: String? = nil
|
||||||
|
|
||||||
|
/// Wait after the command
|
||||||
|
var waitAfterCommand: Bool = false
|
||||||
|
|
||||||
init() {}
|
init() {}
|
||||||
|
|
||||||
init(from config: ghostty_surface_config_s) {
|
init(from config: ghostty_surface_config_s) {
|
||||||
@@ -476,6 +479,9 @@ extension Ghostty {
|
|||||||
// Zero is our default value that means to inherit the font size.
|
// Zero is our default value that means to inherit the font size.
|
||||||
config.font_size = fontSize ?? 0
|
config.font_size = fontSize ?? 0
|
||||||
|
|
||||||
|
// Set wait after command
|
||||||
|
config.wait_after_command = waitAfterCommand
|
||||||
|
|
||||||
// Use withCString to ensure strings remain valid for the duration of the closure
|
// Use withCString to ensure strings remain valid for the duration of the closure
|
||||||
return try workingDirectory.withCString { cWorkingDir in
|
return try workingDirectory.withCString { cWorkingDir in
|
||||||
config.working_directory = cWorkingDir
|
config.working_directory = cWorkingDir
|
||||||
|
@@ -447,6 +447,9 @@ pub const Surface = struct {
|
|||||||
|
|
||||||
/// Input to send to the command after it is started.
|
/// Input to send to the command after it is started.
|
||||||
initial_input: ?[*:0]const u8 = null,
|
initial_input: ?[*:0]const u8 = null,
|
||||||
|
|
||||||
|
// Wait after the command exits
|
||||||
|
wait_after_command: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
||||||
@@ -540,6 +543,11 @@ pub const Surface = struct {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait after command
|
||||||
|
if (opts.wait_after_command) {
|
||||||
|
config.@"wait-after-command" = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize our surface right away. We're given a view that is
|
// Initialize our surface right away. We're given a view that is
|
||||||
// ready to use.
|
// ready to use.
|
||||||
try self.core_surface.init(
|
try self.core_surface.init(
|
||||||
|
Reference in New Issue
Block a user