Skip to content

macos: add AppleScript front window and focused terminal properties - #11251

Merged
mitchellh merged 1 commit into
mainfrom
push-zyokoxpqwopn
Mar 9, 2026
Merged

mitchellh merged 1 commit into
mainfrom
push-zyokoxpqwopn

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

This adds two new propeties to make it easy to get the frontmost (main) window and the focused terminal within a tab. We already had a property to get the selected tab of a tab group.

Examples

Send Input to Focused Terminal

tell application "Ghostty"
  set term to focused terminal of selected tab of front window
  input text "pwd\n" to term
end tell

Split the Focused Terminal

tell application "Ghostty"
  set currentTerm to focused terminal of selected tab of front window
  set newTerm to split currentTerm direction right
  input text "echo split-ready\n" to newTerm
end tell

This adds two new propeties to make it easy to get the frontmost (main)
window and the focused terminal within a tab. We already had a property
to get the selected tab of a tab group.
@mitchellh
mitchellh requested a review from a team as a code owner March 9, 2026 03:01
@mitchellh mitchellh added this to the 1.3.0 milestone Mar 9, 2026
@8bittts

8bittts commented Mar 9, 2026

Copy link
Copy Markdown

I was doing some tests of Applescript and the possibilities are so many! Excited that this was a focus for the team.

@mitchellh

Copy link
Copy Markdown
Contributor Author

I was doing some tests of Applescript and the possibilities are so many! Excited that this was a focus for the team.

Yes! Awesome! Please let me know any weaknesses you find. This PR for example was thanks to some feedback I got from someone writing scripts on X. :)

@mitchellh
mitchellh merged commit b82d452 into main Mar 9, 2026
129 checks passed
@mitchellh
mitchellh deleted the push-zyokoxpqwopn branch March 9, 2026 03:11
@zachdaniel

zachdaniel commented Mar 9, 2026 •

Copy link
Copy Markdown

Last thing I need to perfect my riced up pane switching is a way to run an arbitrary script when pressing a key bind in Ghostty. The specific shape of my problem is that Claude Code consumes all input while open, so nushell never sees my CTRL+hjkl keys typed in to call my AppleScript that intelligently changes windows. If, however, I could execute an AppleScript on a key bind being pressed, then I could check the window title to see if I'm running nvim and if so I could send keys to neovim otherwise tell Ghostty to navigate.

As it stands now I can't find a way to navigate out of a Claude Code window 馃槩

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.

3 participants