import Foundation /// Which app to bring forward when the user clicks an event. public enum TerminalLocator { /// Prefer the macOS bundle id the terminal exports. `TERM_PROGRAM` is a fallback because it names /// the program, not its bundle, so only well-known values are mapped; an unknown one returns nil /// rather than guessing at an app to activate. public static func bundleID(from environment: [String: String]) -> String? { if let id = environment["__CFBundleIdentifier"], !id.isEmpty { return id } guard let program = environment["TERM_PROGRAM"] else { return nil } return knownTerminals[program.lowercased()] } static let knownTerminals: [String: String] = [ "ghostty": "com.mitchellh.ghostty", "apple_terminal": "com.apple.Terminal", "iterm.app": "com.googlecode.iterm2", "wezterm": "com.github.wez.wezterm", "vscode": "com.microsoft.VSCode", ] }