terminal
This directory contains the configurations, action overrides, and voice commands designed to standardize and control command-line interfaces (CLIs) and shells across different operating systems. It decouples high-level terminal concepts (like changing directory, copying text, or searching commands) from the OS-specific commands and shortcuts needed to perform them.
Core Terminal Infrastructure
The core terminal abstraction acts as an API interface for talking to various shells.
- terminal.py: Defines the abstract
useraction classes for terminal operations and handles string-escaping logic (e.g., preparing file paths for insertion). It also adapts file manager commands so that navigating the command-line mirrors interacting with graphical directory viewers (e.g., turning a command to "open directory" into acdcommand). - terminal.talon: Maps natural language voice triggers to these abstract actions. It provides commands like
lisafor listing contents,katiefor changing directories, and triggers for clearing screens, killing processes (kill all), and executing or finding past commands.
Operating System & Shell Adaptation
Because different terminals and shells use distinct commands and syntax, specific context wrappers inherit and implement the core functions defined in terminal.py.
- unix_shell.py: Implements actions when the context
tag: user.generic_unix_shellis active. This script handles standard POSIX-compliant syntax such asls,cd,clear, andctrl-rhistory searches. - windows_shell.py: Implements actions when
tag: user.generic_windows_shellis active, primarily targeting PowerShell syntax. It maps directory listings to PowerShell commands (e.g., usingls -forceto list hidden directories) and manages escaping using backticks (`) instead of the Unix-typical backslashes (\).
Command Line Text Editing (Readline)
Command-line programs do not typically interact with standard GUI text manipulation APIs. Therefore, editing commands like "delete line" or "word left" must be translated into shell-specific keyboard shortcuts.
- readline.py: Maps standard Emacs-like Readline shortcuts (used by default in shells like Bash and Zsh). For example, "word left" is mapped to
alt-b, and "line start" is mapped toctrl-a. It features complex logic to wrap and execute compound edit actions (such as copying, cutting, or deleting selections) while reverting and managing the system clipboard cleanly. - readline_vi.py: Provides a fallback implementation for developers who run their shells in Vi-mode. It converts typical line editing actions into equivalent sequential keystrokes (such as hitting
escape, issuing a Vi movement command, and returning to insert mode withiora).
Unix Utilities Integration
For developer productivity within Unix shells, this directory includes vocabulary definitions to speed up the entry of common CLI utilities.
- unix_utilities.py: Registers a module tag
unix_utilitiesand instantiates a list for common commands. - unix_utilities.talon: Specifies how utility commands are output, ensuring that a space is appended after invoking a utility name (e.g., speaking
core grepinsertsgrepinto the shell). - unix_utility.talon-list: A comprehensive vocabulary mapping spoken words to shell-executable strings (e.g., mapping "disk free human" to
df -h, "make dear" tomkdir, and "pseudo" tosudo).