diff --git a/macos/Ghostty.sdef b/macos/Ghostty.sdef
index 95497a04a..bdfc501fb 100644
--- a/macos/Ghostty.sdef
+++ b/macos/Ghostty.sdef
@@ -9,6 +9,9 @@
+
+
+
@@ -66,6 +69,9 @@
+
+
+
diff --git a/macos/Sources/Features/AppleScript/AppDelegate+AppleScript.swift b/macos/Sources/Features/AppleScript/AppDelegate+AppleScript.swift
index de7b4948c..983217d60 100644
--- a/macos/Sources/Features/AppleScript/AppDelegate+AppleScript.swift
+++ b/macos/Sources/Features/AppleScript/AppDelegate+AppleScript.swift
@@ -57,6 +57,16 @@ extension NSApplication {
return result
}
+ /// Exposed as the AppleScript `front window` property.
+ ///
+ /// `scriptWindows` is already ordered front-to-back, so the first item is
+ /// the frontmost logical Ghostty window.
+ @objc(frontWindow)
+ var frontWindow: ScriptWindow? {
+ guard isAppleScriptEnabled else { return nil }
+ return scriptWindows.first
+ }
+
/// Enables AppleScript unique-ID lookup for window references.
///
/// Required selector name pattern for element key `scriptWindows`:
diff --git a/macos/Sources/Features/AppleScript/ScriptTab.swift b/macos/Sources/Features/AppleScript/ScriptTab.swift
index 8189cd0fa..e5715a4b0 100644
--- a/macos/Sources/Features/AppleScript/ScriptTab.swift
+++ b/macos/Sources/Features/AppleScript/ScriptTab.swift
@@ -67,6 +67,20 @@ final class ScriptTab: NSObject {
return window?.tabIsSelected(controller) ?? false
}
+ /// Exposed as the AppleScript `focused terminal` property.
+ ///
+ /// Uses the currently focused surface for this tab.
+ @objc(focusedTerminal)
+ var focusedTerminal: ScriptTerminal? {
+ guard NSApp.isAppleScriptEnabled else { return nil }
+ guard let controller else { return nil }
+ guard let surface = controller.focusedSurface,
+ controller.surfaceTree.contains(surface)
+ else { return nil }
+
+ return ScriptTerminal(surfaceView: surface)
+ }
+
/// Best-effort native window containing this tab.
var parentWindow: NSWindow? {
guard NSApp.isAppleScriptEnabled else { return nil }