apple_terminal
Apple Terminal Integration
This directory provides Talon voice control integration for the default macOS terminal application, Apple Terminal. It configures context-aware behavior, integrates with shell-related command sets, and overrides key navigation and text editing actions to match standard macOS terminal conventions.
How It Works
The integration is driven by two cooperative files:
apple_terminal.talondefines the voice commands and activates standard behavior tags when the terminal application is active.apple_terminal.pyoverrides Python-level actions for window-title tracking, tab navigation, and editing commands.
Tag Configuration and Voice Commands
By targeting the apple_terminal application context, apple_terminal.talon enables several functional tags that map voice commands to standard CLI behaviors:
terminalanduser.generic_unix_shell: Activates core command structures for working inside a Unix terminal.user.readline: Inherits command shortcuts compatible with GNU Readline (e.g., Emacs-style shell editing keys).user.git,user.anaconda, anduser.kubectl: Exposes specialized voice commands for working with Git, Conda, and Kubernetes.user.tabsanduser.file_manager: Declares that Apple Terminal supports tabbed interfaces and context-aware file management.
Additionally, apple_terminal.talon defines voice commands for job control:
- "suspend": Sends the
ctrl-zkeystroke to pause the current foreground process. - "resume": Types
fgand pressesenterto resume the suspended task in the foreground.
Application and Context Overrides
The apple_terminal.py script implements specialized overrides to match how macOS manages the Terminal process:
- Active Path Detection: It implements
user.file_manager_current_pathby parsing the active window's title. Zsh-based terminals on macOS typically format window titles to show the current path. The script extracts this path, splits off shell metadata, expands user-relative paths (~), and handles directory remapping or exclusions. This allows Talon to remain aware of which directory the terminal is currently navigating. - Tab Navigation: It overrides the standard
app.tab_previousandapp.tab_nextactions to map them to the correct macOS system keys (ctrl-shift-tabandctrl-tab). - Line Deletion: It overrides the standard
edit.delete_linecommand to triggerctrl-u, matching the standard terminal shortcut to clear the current command prompt.