WezTerm config for iTerm users https://vladkens.cc/from-iterm-to-wezterm/ The article provides a WezTerm configuration file (wezterm.lua) designed for users migrating from iTerm2, featuring settings like Catppuccin color schemes, JetBrains Mono font, and macOS window blur effects. The configuration includes custom keybindings, tab bar customization, automatic window maximization on startup, and integration with tmux-like session persistence through Unix socket connections. wezterm.lua This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters -- https://wezfurlong.org/wezterm/config/files.html -- https://alexplescan.com/posts/2024/08/10/wezterm/ -- https://github.com/wez/wezterm/issues/6112 -- https://github.com/wez/wezterm/issues/5754 local wezterm = require "wezterm" local config = wezterm.config builder local action = wezterm.action local mux = wezterm.mux config.audible bell = "Disabled" config.check for updates = false -- managed by brew config.set environment variables = { PATH = '/opt/homebrew/bin:/usr/local/bin/:' .. os.getenv 'PATH' } local function scheme for appearance a return a:find "Dark" and "Catppuccin Macchiato" or "Catppuccin Latte" end config.font = wezterm.font { family = 'JetBrains Mono', weight = 'Medium', harfbuzz features = { 'calt=0', 'clig=0', 'liga=0' } } config.font size = 15.0 config.line height = 1.0 config.bold brightens ansi colors = true config.color scheme = scheme for appearance wezterm.gui.get appearance config.macos window background blur = 20 config.window background opacity = 0.96 config.window decorations = 'RESIZE|INTEGRATED BUTTONS' config.window padding = { left = '0.5cell', right = '0.5cell', top = '1.5cell', bottom = '0.5cell' } config.enable tab bar = true config.use fancy tab bar = false config.tab bar at bottom = true config.tab max width = 32 config.show new tab button in tab bar = false -- config.hide tab bar if only one tab = true -- sometimes procude wrong window size on maximize config.default cursor style = 'BlinkingBar' config.animation fps = 1 config.cursor blink rate = 500 config.prefer egl = true config.max fps = 60 config.enable scroll bar = true config.scrollback lines = 10000 -- makes wezterm to work like tmux; see also: https://bower.sh/zmx-session-persistence config.default gui startup args = { 'connect', 'unix' } config.window close confirmation = 'NeverPrompt' local function maximize window window if not window.gui window then return end local screen = wezterm.gui.screens .active local guiwin = window:gui window if not screen or not guiwin then return end -- window:gui window :maximize -- have long animation guiwin:set position screen.x, screen.y guiwin:set inner size screen.width, screen.height end -- https://github.com/wez/wezterm/issues/3299 issuecomment-2145712082 wezterm.on "gui-startup", function cmd local tab, pane, window = mux.spawn window cmd or {} maximize window window end wezterm.on "gui-attached", function window local workspace = mux.get active workspace for , window in ipairs mux.all windows do if window:get workspace == workspace then maximize window window end end end wezterm.on "window-resized", function window, pane maximize window window end -- see also https://wezterm.org/config/lua/wezterm/battery info.html wezterm.on "format-tab-title", function tab, tabs, panes, config, hover, max width local title = tab.tab title ~= "" and tab.tab title or tab.active pane.title title = title:lower local prefix = tostring tab.tab index + 1 .. ":" local width = math.max 1, max width - prefix + 2 title = wezterm.truncate right title, width return " " .. prefix .. title .. " " end -- https://github.com/wezterm/wezterm/issues/1988 issuecomment-2462216249 local function search cmd window, pane window:perform action action.Search 'CurrentSelectionOrEmptyString', pane window:perform action action.Multiple { action.CopyMode 'ClearPattern', action.CopyMode 'ClearSelectionMode', action.CopyMode 'MoveToScrollbackBottom' }, pane end config.keys = { { key = 'q', mods = 'CMD', action = wezterm.action.Nop }, -- prevent accidental quit { key = 't', mods = 'CMD', action = action.SpawnTab 'CurrentPaneDomain' }, { key = 'd', mods = 'CMD', action = action.SplitHorizontal { domain = 'CurrentPaneDomain' } }, { key = 'd', mods = 'CMD|SHIFT', action = action.SplitVertical { domain = 'CurrentPaneDomain' } }, { key = 'k', mods = 'CMD', action = action.ClearScrollback 'ScrollbackAndViewport' }, { key = 'w', mods = 'CMD', action = action.CloseCurrentPane { confirm = false } }, { key = 'w', mods = 'CMD|SHIFT', action = action.CloseCurrentTab { confirm = false } }, { key = 'a', mods = 'CMD', action = action.SelectTextAtMouseCursor 'SemanticZone', }, { key = 'LeftArrow', mods = 'CMD', action = action.SendKey { key = 'Home' } }, { key = 'RightArrow', mods = 'CMD', action = action.SendKey { key = 'End' } }, { key = 'Backspace', mods = 'CMD', action = action.SendKey { mods = "CTRL", key = "u" } }, { key = 'Backspace', mods = 'OPT', action = action.SendKey { mods = "CTRL", key = "w" } }, { key = 'P', mods = 'CMD|SHIFT', action = action.ActivateCommandPalette }, { key = 'f', mods = 'CMD', action = wezterm.action callback search cmd }, { key = ',', mods = 'CMD', action = action.SpawnCommandInNewTab { cwd = wezterm.home dir, args = { 'code', wezterm.config file } } }, { key = 'E', mods = 'CMD|SHIFT', action = action.PromptInputLine { description = 'Enter tab title empty to unset :', action = wezterm.action callback function window, , line window:active tab :set title line end , }}, } config.mouse bindings = { { event = { Up = { streak = 1, button = "Left" } }, mods = "NONE", action = action.Nop }, { event = { Up = { streak = 1, button = "Left" } }, mods = "CMD", action = action.OpenLinkAtMouseCursor }, -- Disable CMD + LeftClick window drag make it behave like normal select -- { event = { Drag = { streak = 1, button = 'Left' } }, mods = "CMD", action = action.Nop }, { event = { Drag = { streak = 1, button = "Left" } }, mods = "CMD", action = action.ExtendSelectionToMouseCursor "Cell" }, } -- https://code.visualstudio.com/docs/configure/command-line opening-vs-code-with-urls -- path-symbols: \w@\.\/\-\ \ \ \ local function path exists path local ok, , = wezterm.run child process { "test", "-e", path } return ok end config.hyperlink rules = wezterm.default hyperlink rules -- config.hyperlink rules = {} table.insert config.hyperlink rules, { regex = ?: \w@\.\/\-\ \ \ \ +\/ + \w@\.\/\-\ \ \ \ +\.\w+ \b , format = "vscode://file/$PWD/$1", highlight = 1, } table.insert config.hyperlink rules, { regex = ?: \w@\.\/\-\ \ \ \ +\/ + \w@\.\/\-\ \ \ \ +\.\w+ : \d+ : \d+ , format = "vscode://file/$PWD/$1:$2:$3", highlight = 1, } wezterm.on "open-uri", function window, pane, uri if uri:find "$PWD" then local cwd uri = pane:get current working dir local before, after = uri:match "^ .- $PWD/ .+ $" wezterm.log info before, after, path exists after if path exists after then uri = before .. after else uri = uri:gsub "$PWD", cwd uri.file path end wezterm.log info uri wezterm.open with uri return false end return true end return config