wezterm module is the primary module that exposes WezTerm configuration and control to your Lua config file. It provides functions for font configuration, formatting, actions, and various utility functions.
Importing the Module
You will typically place this at the top of your configuration file:Core Functions
The wezterm module provides several categories of functions:Configuration
- config_builder() - Create a configuration builder object with enhanced error checking
config_dir- Path to the directory containing your configuration fileconfig_file- Path to your configuration fileexecutable_dir- Directory containing the wezterm executablehome_dir- Path to the user’s home directory
Font Functions
- font() - Configure a single font with attributes
- font_with_fallback() - Configure fonts with fallback support
Formatting and Text
- format() - Format text with colors and attributes
column_width()- Calculate the column width of a stringpad_left()- Pad string to width on the leftpad_right()- Pad string to width on the righttruncate_left()- Truncate string from the lefttruncate_right()- Truncate string from the right
Actions
- action - Key assignment action constructors
action_callback()- Create custom action callbackshas_action()- Check if an action exists
Utility Functions
log_error()- Log error messageslog_info()- Log info messageslog_warn()- Log warning messagesrun_child_process()- Execute a child processsleep_ms()- Sleep for millisecondshostname()- Get the system hostnameversion- WezTerm version stringtarget_triple- Rust compilation target triple
State Management
GLOBAL- Global in-memory state storage that persists across config reloadsemit()- Emit custom eventson()- Register event handlers
Color Schemes
get_builtin_color_schemes()- Get all built-in color schemesgradient_colors()- Generate gradient colors
Platform Detection
running_under_wsl()- Check if running under WSLdefault_wsl_domains()- Get default WSL domainsdefault_ssh_domains()- Get default SSH domains
Basic Usage Example
Version Information
You can access version information to conditionally enable features:Next Steps
- Learn about config_builder() for better error checking
- Explore font configuration options
- Understand actions for key bindings
- Use format() for styled text in status bars