GUI events are emitted by WezTerm’s graphical user interface layer during application startup and attachment to domains. These events allow you to customize the initial state of your terminal environment.
local wezterm = require 'wezterm'local mux = wezterm.muxlocal config = {}wezterm.on('gui-startup', function(cmd) local tab, pane, window = mux.spawn_window(cmd or {}) -- Create a split occupying the right 1/3 of the screen pane:split { size = 0.3 } -- Create another split in the remaining 2/3 pane:split { size = 0.5 }end)return config
local wezterm = require 'wezterm'local mux = wezterm.muxwezterm.on('gui-attached', function(domain) -- Maximize all displayed windows on startup local workspace = mux.get_active_workspace() for _, window in ipairs(mux.all_windows()) do if window:get_workspace() == workspace then window:gui_window():maximize() end endend)local config = wezterm.config_builder()return config
wezterm.on('gui-attached', function(domain) local domain_name = domain:name() if domain_name == 'SSH:production' then -- Set visual indicator for production for _, window in ipairs(mux.all_windows()) do local overrides = window:get_config_overrides() or {} overrides.color_scheme = 'Red Alert' window:set_config_overrides(overrides) end endend)
local projects = { web = { dir = wezterm.home_dir .. '/projects/web', splits = { 'npm run dev', 'git status' } }, api = { dir = wezterm.home_dir .. '/projects/api', splits = { 'docker-compose up', 'npm test -- --watch' } }}wezterm.on('gui-startup', function(cmd) for name, project in pairs(projects) do local tab, pane, window = mux.spawn_window { workspace = name, cwd = project.dir, } for i, command in ipairs(project.splits) do if i > 1 then pane = pane:split { size = 0.5 } end pane:send_text(command .. '\n') end end mux.set_active_workspace 'web'end)
wezterm.on('gui-startup', function(cmd) local tab, pane, window = mux.spawn_window(cmd or {}) local gui_window = window:gui_window() -- Get screen dimensions local screens = wezterm.gui.screens() local active_screen = screens.active if active_screen.width > 2560 then -- Ultra-wide monitor: position on right half gui_window:set_position(active_screen.width / 2, 0) gui_window:set_inner_size(active_screen.width / 2, active_screen.height) else -- Normal monitor: maximize gui_window:maximize() endend)