diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist index eb64fed93..950fd73cc 100644 --- a/macos/Ghostty-Info.plist +++ b/macos/Ghostty-Info.plist @@ -2,6 +2,21 @@ + CFBundleDocumentTypes + + + CFBundleTypeName + Folders + CFBundleTypeRole + Editor + LSHandlerRank + Alternate + LSItemContentTypes + + public.directory + + + LSEnvironment GHOSTTY_MAC_APP diff --git a/macos/Sources/AppDelegate.swift b/macos/Sources/AppDelegate.swift index 53c6c159c..ba6f19fd6 100644 --- a/macos/Sources/AppDelegate.swift +++ b/macos/Sources/AppDelegate.swift @@ -138,6 +138,23 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp return false } + func application(_ sender: NSApplication, openFile filename: String) -> Bool { + AppDelegate.logger.warning("OPEN FILE=\(filename)") + + // Build our config + var config = Ghostty.SurfaceConfiguration() + config.workingDirectory = filename + + // If we don't have a window open through the window manager, we launch + // a new window. + guard let mainWindow = windowManager.mainWindow else { + windowManager.addNewWindow(withBaseConfig: config) + return true + } + + return false + } + /// This is called for the dock right-click menu. func applicationDockMenu(_ sender: NSApplication) -> NSMenu? { return dockMenu diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 8fbf9adf9..de8a434a4 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -199,8 +199,6 @@ extension Ghostty { init(from config: ghostty_surface_config_s) { self.fontSize = config.font_size self.workingDirectory = String.init(cString: config.working_directory, encoding: .utf8) - let blah = workingDirectory! - AppDelegate.logger.warning("OPEN from=\(blah)") } /// Returns the ghostty configuration for this surface configuration struct. The memory