Skip to content

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.talon defines the voice commands and activates standard behavior tags when the terminal application is active.
  • apple_terminal.py overrides 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:

  • terminal and user.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, and user.kubectl: Exposes specialized voice commands for working with Git, Conda, and Kubernetes.
  • user.tabs and user.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-z keystroke to pause the current foreground process.
  • "resume": Types fg and presses enter to 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_path by 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_previous and app.tab_next actions to map them to the correct macOS system keys (ctrl-shift-tab and ctrl-tab).
  • Line Deletion: It overrides the standard edit.delete_line command to trigger ctrl-u, matching the standard terminal shortcut to clear the current command prompt.