Hi! I’ve been using Kakoune with Ghostty for the past couple of weeks using this plugin . It works well but :focus only works on the nightly build. Just to spread awareness and rack up internet points.
I have also opened Support windowing in Ghostty by lrworth · Pull Request #5524 · mawww/kakoune · GitHub in case someone wants this built-in to Kakoune (otherwise I’d consider packaging the plugin better).
2 Likes
I’m wondering if +new-window action will be supported on macOS. Zed has Zed > Install CLI from the application menu. Something equivalent could be nice for macOS.
Is there a way to get the terminal associated to %val{client_pid}?
Technically, eval -client kak_client_in_given_ghostty_terminal ghostty-terminal-vertical kak -c %val{session} should do the correct thing.
Amazing!
I just added some suggestions for making the pull request more friendly for Linux users. I’ve been using Ghostty with Kakoune on Linux for months now.
It’s a bummer that there’s no CLI options for handling splits, tabs, etc. outside of AppleScript. But creating new windows works for me just fine.
Maybe eventually that will get built out for the Linux people.
Wow, well spotted. I think this is actually impossible to get working in Ghostty 1.3.1 (latest release right now) but nightly gives terminal a tty property which I used in ghostty-focus. I’ll see if I can update so your command works.
1 Like
tty PR also comes with a pid property that refers to the “PID of the foreground process in this terminal.”, so we can directly match to the %val{client_pid} value.
ghostty-org:main ← TweedBeetle:pid-tty-applescript
opened 11:55AM - 28 Mar 26 UTC
## Summary
Add `pid` and `tty` as read-only properties to:
- The AppleScript `t… erminal` class
- The App Intents `TerminalEntity`
This enables reliable process-to-terminal mapping for automation tools when multiple terminals share the same working directory.
## Changes
- `macos/Ghostty.sdef`: add `pid` and `tty` to the `terminal` class
- `macos/Sources/Features/AppleScript/ScriptTerminal.swift`: add AppleScript getters
- `macos/Sources/Ghostty/Ghostty.Surface.swift`: add Swift accessors for foreground PID and PTY name
- `src/apprt/embedded.zig`: add C bridge exports for foreground PID and PTY name
- `include/ghostty.h`: declare the new C API entry points
- `macos/Sources/Features/App Intents/Entities/TerminalEntity.swift`: surface the same values in App Intents
## Testing
- `zig build -Demit-macos-app=false`
- `/opt/homebrew/bin/nu macos/build.nu --configuration Debug --action build`
- `swiftlint lint 'macos/Sources/Features/AppleScript/ScriptTerminal.swift'`
- `swiftlint lint 'macos/Sources/Features/App Intents/Entities/TerminalEntity.swift'`
- `swiftlint lint 'macos/Sources/Ghostty/Ghostty.Surface.swift'`
- AppleScript smoke test against the built app:
- `get {id, pid, tty, working directory} of terminal 1`
- `get pid of every terminal`
- `get tty of every terminal`
- Verified returned `pid`/`tty` against `ps -p <pid> -o pid=,tty=,comm=` and `lsof -a -p <pid> -d cwd -Fn`
## AI Disclosure
This PR was developed with AI assistance (Codex). The contributor understands the changes and can explain the implementation.
Closes #11592
Closes #10756
1 Like