tmux
This directory contains the configuration and Python scripts required to control the tmux terminal multiplexer using Talon voice commands. It maps standard Talon commands for managing tabs and split windows directly to tmux windows and panes, allowing you to seamlessly navigate complex terminal layouts.
How It Works
The tmux integration works by overriding Talon's built-in actions for tabs and splits. Instead of sending standard GUI application keys, Talon translates your voice commands into tmux keystrokes and command-line instructions.
- Prefix Configuration: By default, tmux uses
ctrl-bas its prefix. This is defined as a customizable Talon setting (user.tmux_prefix_key) in tmux.py. - Command Execution: tmux.py provides internal helper actions like
tmux_execute_commandandtmux_execute_command_with_confirmation. These helper methods enter tmux command-line mode (:), insert the target tmux command (e.g.,split-paneorkill-window), and handle confirmation prompts if necessary.
Core Components
Python Action Overrides
The tmux.py file is the heart of the integration. It registers the tmux application context and overrides key actions:
- Tabs to Windows: Standard tab actions like opening, closing, and jumping to tabs are mapped to tmux window management commands (
new-window,select-window,kill-window). - Splits to Panes: Standard split-screen actions (e.g., splitting vertically, splitting horizontally, switching focus, and clearing splits) are mapped directly to tmux pane operations like
split-pane,swap-pane,select-pane, andkill-pane.
Talon Keymaps
The directory contains two Talon files that define spoken commands:
- tmux.talon: Actives the standard
user.splitsanduser.tabstags when tmux is focused. It also includes commands to navigate splits by direction or view pane numbers. - tmux_linux.talon: Offers a dedicated Linux-specific command set prefixed with "mux" (e.g., "mux new session", "mux split horizontal", "mux next pane"). This file relies on direct key emulation (e.g., sending
ctrl-bfollowed by%or") rather than sending strings to the tmux command line.
Setup and Activation
Because tmux runs inside a terminal, Talon cannot always detect it automatically. To enable these commands:
- Review the instructions in tmux.talon.
- Add a custom matcher in your personal user directory to detect when tmux is running (for example, by matching the window title regex
/^tmux/). - Activate the
user.tmuxtag when the matcher is triggered.