mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 02:36:22 +03:00
config: add quit-after-last-window-closed
Whether or not to quit after the last window is closed. This defaults to false. Currently only supported on macOS.
This commit is contained in:
@ -82,6 +82,10 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp
|
|||||||
NSApp.servicesProvider = ServiceProvider()
|
NSApp.servicesProvider = ServiceProvider()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||||
|
return ghostty.shouldQuitAfterLastWindowClosed
|
||||||
|
}
|
||||||
|
|
||||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
||||||
let windows = NSApplication.shared.windows
|
let windows = NSApplication.shared.windows
|
||||||
if (windows.isEmpty) { return .terminateNow }
|
if (windows.isEmpty) { return .terminateNow }
|
||||||
|
@ -51,6 +51,15 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// True if we should quit when the last window is closed.
|
||||||
|
var shouldQuitAfterLastWindowClosed: Bool {
|
||||||
|
guard let config = self.config else { return true }
|
||||||
|
var v = false;
|
||||||
|
let key = "quit-after-last-window-closed"
|
||||||
|
_ = ghostty_config_get(config, &v, key, UInt(key.count))
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
/// True if we need to confirm before quitting.
|
/// True if we need to confirm before quitting.
|
||||||
var needsConfirmQuit: Bool {
|
var needsConfirmQuit: Bool {
|
||||||
guard let app = app else { return false }
|
guard let app = app else { return false }
|
||||||
|
@ -430,6 +430,10 @@ keybind: Keybinds = .{},
|
|||||||
/// to true. If set to false, surfaces will close without any confirmation.
|
/// to true. If set to false, surfaces will close without any confirmation.
|
||||||
@"confirm-close-surface": bool = true,
|
@"confirm-close-surface": bool = true,
|
||||||
|
|
||||||
|
/// Whether or not to quit after the last window is closed. This defaults
|
||||||
|
/// to false. Currently only supported on macOS.
|
||||||
|
@"quit-after-last-window-closed": bool = false,
|
||||||
|
|
||||||
/// Whether to enable shell integration auto-injection or not. Shell
|
/// Whether to enable shell integration auto-injection or not. Shell
|
||||||
/// integration greatly enhances the terminal experience by enabling
|
/// integration greatly enhances the terminal experience by enabling
|
||||||
/// a number of features:
|
/// a number of features:
|
||||||
|
Reference in New Issue
Block a user