Skip to content

git

This directory contains a suite of Talon configuration and script files that provide powerful voice control for Git operations in terminal environments. By mapping voice commands to Git commands, flags, and interactive prompts, it streamlines standard version control workflows.

Vocabulary and Argument Parsing

The foundation of the Git integration is built on mapping spoken phrases to CLI parameters:

  • git.py: Defines the structure of the Git vocabulary. It registers two list types (git_command and git_argument) and exposes a Talon capture rule, user.git_arguments, which aggregates sequential spoken arguments and formats them separated by spaces.
  • git_command.talon-list: Maps spoken words to primary Git commands. For example, speaking "in it" maps to init, and "cherry pick" maps to cherry-pick.
  • git_argument.talon-list: Maps spoken phrases to Git flags (e.g., "force with lease" maps to --force-with-lease, "staged" to --staged) as well as common branch/remote targets like HEAD, origin, and upstream.

Executing Git Commands

The primary voice-to-keystroke mappings are handled in git.talon. This file applies when the terminal tag and the user.git tag are active, offering three main categories of interactions:

  1. Dynamic Command Generation: Using the pattern git {user.git_command} [<user.git_arguments>], Talon can generate almost any arbitrary Git CLI statement on the fly. Special rules exist for complex commands, such as commits or stashing with messages:
    • "git commit message <prose>" inserts git commit --message "<prose>" and places the cursor between the quotes.
  2. Optimistic Execution: For read-only or low-risk commands (like git status or git diff), the commands are instantly executed in the terminal (by appending \n to the insertion) to save the user from having to verbally say "enter".
  3. Clipboard and Highlight Integration: Enables quick automation using the system clipboard or selected text. Commands like "git clone clipboard" write out the clone command, paste the copied repository URL, and press enter.

Interactive Patch Staging

When reviewing code changes piece-by-piece using Git's interactive patching tool (git add -p), the system command-line output typically updates the window title.

git_add_patch.talon activates dynamically when the window title matches /git add .*\-p/. It overrides standard terminal behavior to provide short, high-efficiency single-character commands:

  • "yank" stages the current hunk (y)
  • "near" skips the current hunk (n)
  • "quench" exits the interactive session (q)
  • "drum" splits the current hunk into smaller hunks (d)
  • "air" stages all remaining hunks in the file (a)

Each of these voice commands automatically appends a carriage return to immediately submit the choice.