Skip to main content

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.lua or ~/.wezterm.lua
  • Windows: %USERPROFILE%\.config\wezterm\wezterm.lua or %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 internal Config 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 the wezterm module:

Type Information and Defaults

Most configuration options have sensible defaults. You can check the current value of any option using:
number
default:"12.0"
The font size measured in points. Default is platform-dependent.
number
default:"24"
The height of a new window in character cells.
number
default:"80"
The width of a new window in character cells.

Automatic Configuration Reloading

boolean
default:"true"
When true, WezTerm will automatically reload your configuration file when it detects changes.
This means you can edit your wezterm.lua file and see changes take effect immediately in running WezTerm instances.
Some configuration changes require creating a new tab or window to take full effect, particularly those related to spawning new processes or domain configuration.

Debugging Configuration

WezTerm provides several tools for debugging your configuration:

Logging

Configuration Errors

If there’s an error in your configuration file, WezTerm will:
  1. Display an error message in a notification
  2. Log the error to the WezTerm log file
  3. Fall back to default configuration

Show Configuration

You can view the resolved configuration using:
This shows all configuration values, including defaults.

Best Practices

  1. Use config_builder(): Always use wezterm.config_builder() for better error messages
  2. Organize your config: Split large configurations into multiple files using require()
  3. Comment your code: Document non-obvious configuration choices
  4. Test incrementally: Add configuration options gradually and test each change
  5. Use version checks: Guard new features with version checks for backward compatibility

Next Steps

Explore specific configuration areas:

See Also