Skip to content

support ghostty#74

Open
tomkrus007 wants to merge 2 commits into
jbtule:masterfrom
tomkrus007:master
Open

support ghostty#74
tomkrus007 wants to merge 2 commits into
jbtule:masterfrom
tomkrus007:master

Conversation

@tomkrus007

Copy link
Copy Markdown

support ghostty

Copilot AI review requested due to automatic review settings April 16, 2026 07:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 osascript to 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-app setting 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.

Comment on lines +46 to +69
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];

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 9 to +11
#import <Cocoa/Cocoa.h>
#import <ScriptingBridge/ScriptingBridge.h>
#import <ApplicationServices/ApplicationServices.h>

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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).

Copilot uses AI. Check for mistakes.
Comment thread README.md
To support ghostty:

```bash
defaults write name.tuley.jay.cd-to cdto-terminal-app ghostty

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
defaults write name.tuley.jay.cd-to cdto-terminal-app ghostty
defaults write name.tuley.jay.cd-to cdto-terminal-app -string "ghostty"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants