wezterm.action module provides constructors for defining key assignment actions in your configuration file. It offers an ergonomic way to express keyboard shortcuts, mouse bindings, and other input actions.
Overview
wezterm.action is a special enum constructor type that makes it easier to define actions compared to the older table-based syntax. It provides:
- Type-safe action constructors
- Autocomplete-friendly syntax
- Clear error messages for typos
- Backward compatibility with older configs
Constructor Syntax
Indexingwezterm.action with a valid KeyAssignment name acts as a constructor for that action type.
Action Types
Unit Variants (No Parameters)
Actions that don’t require parameters can be referenced directly:Actions with Default Parameters
Some actions have optional parameters and can be used with or without arguments:Tuple Variants (Positional Parameters)
Actions with positional parameters are called like functions:Common Actions
Tab Management
Pane Management
Font Size
Scrollback
Copy and Paste
Search and Selection
Multiple Actions
Execute multiple actions with a single key press:Workspace Management
Key Tables
Activate custom key tables for modal key bindings:Custom Events
Emit custom events that can be handled with event handlers:Checking Action Availability
You can check if an action exists before using it:Older Syntax (Pre-20220624)
For backward compatibility, the older table syntax is still supported:The new constructor syntax is recommended for all new configurations as it provides better type checking and clearer syntax.
Using Aliases
For brevity, create a shortcut alias:Key Assignment Categories
Actions are available for:- Tabs: Spawn, close, activate, move tabs
- Panes: Split, close, navigate, resize panes
- Scrollback: Scroll by page/line, search, clear
- Copy/Paste: Copy to clipboard, paste from clipboard
- Font: Increase, decrease, reset font size
- Window: Toggle fullscreen, hide, quit
- Workspaces: Switch, create workspaces
- Launchers: Show launcher, tab navigator
- Custom: Emit events, run callbacks
Related Functions
- wezterm.action_callback() - Create custom action callbacks
- wezterm.has_action() - Check if action exists
- wezterm.on() - Register event handlers
Source Reference
Implementation:config/src/lua.rs:345