Lua Configuration Overview
WezTerm uses Lua for configuration, providing a powerful and flexible way to customize every aspect of your terminal emulator. This guide covers the fundamentals of WezTerm’s Lua configuration system.Configuration File Location
WezTerm looks for a configuration file at:- Unix/Linux/macOS:
~/.config/wezterm/wezterm.luaor~/.wezterm.lua - Windows:
%USERPROFILE%\.config\wezterm\wezterm.luaor%USERPROFILE%\.wezterm.lua
Basic Configuration Structure
A minimal WezTerm configuration file follows this structure:Using
wezterm.config_builder() provides better error messages and validation compared to using a plain Lua table.The Config Object
The configuration is represented as a Lua table that gets converted into WezTerm’s internalConfig struct. You can set any configuration option as a field on this table.
Common Configuration Patterns
Configuration Categories
WezTerm configuration options are organized into several categories:Appearance & Colors
- Color Schemes: Pre-built color themes for your terminal
- Custom Colors: Define your own color palettes
- Tab Bar: Customize tab appearance and behavior
- Window Frame: Configure window decorations and title bar
Fonts
- Font Selection: Choose primary and fallback fonts
- Font Sizing: Configure size, line height, and cell width
- Font Rules: Apply different fonts based on text attributes (bold, italic)
- Font Rendering: Control anti-aliasing, hinting, and other rendering options
Window & Panes
- Window Size: Set initial dimensions
- Padding: Control spacing around terminal content
- Decorations: Configure title bars and window chrome
- Background: Set background colors, images, or gradients
Key Bindings
- Key Assignments: Map keys to actions
- Key Tables: Create modal key binding sets
- Leader Key: Configure Tmux-style leader key patterns
- Mouse Bindings: Customize mouse button actions
Domains & Multiplexing
- SSH Domains: Connect to remote systems
- Unix Domains: Local multiplexing
- WSL Domains: Windows Subsystem for Linux integration
Using the WezTerm API
WezTerm provides a rich API through thewezterm module:
Type Information and Defaults
Most configuration options have sensible defaults. You can check the current value of any option using:The font size measured in points. Default is platform-dependent.
The height of a new window in character cells.
The width of a new window in character cells.
Automatic Configuration Reloading
When true, WezTerm will automatically reload your configuration file when it detects changes.
wezterm.lua file and see changes take effect immediately in running WezTerm instances.
Debugging Configuration
WezTerm provides several tools for debugging your configuration:Logging
Configuration Errors
If there’s an error in your configuration file, WezTerm will:- Display an error message in a notification
- Log the error to the WezTerm log file
- Fall back to default configuration
Show Configuration
You can view the resolved configuration using:Best Practices
- Use config_builder(): Always use
wezterm.config_builder()for better error messages - Organize your config: Split large configurations into multiple files using
require() - Comment your code: Document non-obvious configuration choices
- Test incrementally: Add configuration options gradually and test each change
- Use version checks: Guard new features with version checks for backward compatibility
Next Steps
Explore specific configuration areas:- Color Schemes - Customize your terminal colors
- Fonts - Configure font rendering and selection
- Window Configuration - Control window appearance and behavior
- Key Bindings - Customize keyboard shortcuts