support ghostty#74
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for opening the Finder-selected directory in Ghostty (in addition to the existing Terminal.app behavior), controlled via a user defaults setting.
Changes:
- Add Ghostty integration by invoking
osascriptto open a new Ghostty window/tab with a configured working directory. - Refactor Terminal.app opening logic into a dedicated helper function and route based on
cdto-terminal-app. - Document the new
cdto-terminal-appsetting in the README.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cd to .../cd to .../main.m | Adds Ghostty open path via AppleScript/osascript, and refactors Terminal open logic behind a preference switch. |
| README.md | Documents how to enable Ghostty via defaults write. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| NSTask* task = [[NSTask alloc] init]; | ||
| task.executableURL = [NSURL fileURLWithPath:@"/usr/bin/osascript"]; | ||
| task.arguments = @[ | ||
| @"-e", @"on run argv", | ||
| @"-e", @"set workingDir to item 1 of argv", | ||
| @"-e", @"tell application \"Ghostty\"", | ||
| @"-e", @"set cfg to new surface configuration", | ||
| @"-e", @"set initial working directory of cfg to workingDir", | ||
| @"-e", @"if it is running then", | ||
| @"-e", @"if (count of windows) > 0 then", | ||
| @"-e", @"new tab in front window with configuration cfg", | ||
| @"-e", @"else", | ||
| @"-e", @"new window with configuration cfg", | ||
| @"-e", @"end if", | ||
| @"-e", @"else", | ||
| @"-e", @"new window with configuration cfg", | ||
| @"-e", @"end if", | ||
| @"-e", @"activate", | ||
| @"-e", @"end tell", | ||
| @"-e", @"end run", | ||
| @"--", workingDir | ||
| ]; | ||
| [task launch]; | ||
| [task waitUntilExit]; |
There was a problem hiding this comment.
NSTask is configured via executableURL, but the code calls -launch. With executableURL set, the supported API is -launchAndReturnError: (or set launchPath instead). As written this can raise an exception at runtime (or fail to start the task) and Ghostty won’t open.
| #import <Cocoa/Cocoa.h> | ||
| #import <ScriptingBridge/ScriptingBridge.h> | ||
| #import <ApplicationServices/ApplicationServices.h> |
There was a problem hiding this comment.
#import <ApplicationServices/ApplicationServices.h> appears unused in this file. If nothing from ApplicationServices is needed for the Ghostty integration, please remove it to avoid unused-import warnings (or keep it only if required elsewhere).
| To support ghostty: | ||
|
|
||
| ```bash | ||
| defaults write name.tuley.jay.cd-to cdto-terminal-app ghostty |
There was a problem hiding this comment.
The README example writes cdto-terminal-app without specifying the type; other examples use -bool / -string. To avoid defaults inferring an unexpected type (and to be consistent), use -string "ghostty" in the command.
| defaults write name.tuley.jay.cd-to cdto-terminal-app ghostty | |
| defaults write name.tuley.jay.cd-to cdto-terminal-app -string "ghostty" |
support ghostty