diff --git a/src-tauri/src/agents/launch.rs b/src-tauri/src/agents/launch.rs index f01511f..ca28d9f 100644 --- a/src-tauri/src/agents/launch.rs +++ b/src-tauri/src/agents/launch.rs @@ -31,6 +31,14 @@ fn macos_iterm2_installed() -> bool { .is_some_and(|home| home.join("Applications/iTerm.app").is_dir()) } +#[cfg(target_os = "macos")] +fn macos_ghostty_installed() -> bool { + Path::new("/Applications/Ghostty.app").is_dir() + || env::var_os("HOME") + .map(PathBuf::from) + .is_some_and(|home| home.join("Applications/Ghostty.app").is_dir()) +} + #[cfg(target_os = "linux")] fn linux_terminal_definitions() -> &'static [( &'static str, @@ -69,6 +77,9 @@ pub(crate) fn available_agent_terminals() -> Vec { if macos_iterm2_installed() { options.push(terminal_option("iterm2", "iTerm2")); } + if macos_ghostty_installed() { + options.push(terminal_option("ghostty", "Ghostty")); + } } #[cfg(target_os = "windows")] { @@ -1178,6 +1189,11 @@ fn launch_cli_agent( "tell application \"iTerm2\"\nactivate\nset newWindow to (create window with default profile)\ntell current session of newWindow\nwrite text \"{}\"\nend tell\nend tell", command_line.replace('\\', "\\\\").replace('"', "\\\"") ) + } else if terminal == "ghostty" { + format!( + "tell application \"Ghostty\"\nactivate\nset surfaceConfig to new surface configuration\nset initial input of surfaceConfig to \"{}\\n\"\nnew window with configuration surfaceConfig\nend tell", + command_line.replace('\\', "\\\\").replace('"', "\\\"") + ) } else if matches!(terminal, "auto" | "terminal") { format!( "tell application \"Terminal\"\nactivate\ndo script \"{}\"\nend tell",