Skip to content

powershell

This directory contains the Talon configuration and scripting files to support voice control for Windows PowerShell, running either as a standalone application or hosted inside Windows Terminal.

It integrates PowerShell with Talon's unified terminal and file manager ecosystems, allowing you to use voice commands to navigate directories, manage files, and run tools like Git or Anaconda.

How It Works

PowerShell doesn't natively expose its active directory to external tools in a standardized, cross-platform way. This integration solves that problem by reading the current path from the window title.

The directory consists of three core components:

  • Application Activation (powershell_win.talon): Detects when PowerShell is active and applies relevant command tags.
  • Context-Specific Actions (powershell_win.py): Implements file manager navigation and window-title management tailored to PowerShell.
  • Shell Setup Guide (README.md): Documents the necessary Windows PowerShell profile modifications required to expose the current working directory via the window title.

Detailed Component Breakdown

App Context and Tags

The powershell_win.talon file defines when these commands are active. It targets Windows environments where the active application is powershell.exe, Windows PowerShell, or a windows_terminal window with "PowerShell" in the title.

When active, it assigns several tags:

  • terminal: Enables standard terminal commands.
  • user.generic_windows_shell: Activates basic Windows-style command-line behaviors.
  • user.file_manager: Allows Talon's generic file-navigation voice commands (like "go parent" or "go <directory>") to control the PowerShell prompt.
  • Tool-specific tags (user.git, user.anaconda): Exposes context-aware commands for popular command-line utilities.

File Manager Integration

Because Talon's file_manager actions need to know "where" the terminal currently is, powershell_win.py overrides several system actions:

  • user.file_manager_current_path(): Reads the title of the active window and sanitizes it (removing prefixes like Administrator: or Windows PowerShell:) to parse the current directory path.
  • user.file_manager_open_directory(path): Translates a request to navigate to a directory into an injected cd "{path}" command, followed by an Enter keystroke.
  • user.file_manager_refresh_title(): Dynamically updates the PowerShell host title by injecting a command to set $Host.UI.RawUI.WindowTitle. This ensures Talon immediately registers the location change without waiting for the next shell prompt.

Additionally, this file overrides edit.delete_line to send the Escape key, matching the default PowerShell keybinding to clear the current command line.

Required Shell Configuration

To make this seamless, PowerShell must actively output the current path to its window title. The README.md details how to set this up by editing your PowerShell $profile.

Adding the following custom prompt function ensures that the current directory ($pwd) is always written to the window title whenever the prompt renders:

function prompt {
  $Host.UI.RawUI.WindowTitle = 'Windows PowerShell: ' +  $(get-location)
  "$pwd" + '> '
}

Once this configuration is active, you can set the Talon setting user.powershell_always_refresh_title to false to prevent Talon from redundantly typing out the title-refresh command after every directory change.