My wezterm configuration. Allows workspace configurations with environment variables for each new workspace pane.
| 1 | local wezterm = require("wezterm") |
| 2 | local utils = require("utils") |
| 3 | local act = wezterm.action |
| 4 | local mux = wezterm.mux |
| 5 | local config = wezterm.config_builder() |
| 6 | |
| 7 | -- basic config |
| 8 | config.default_domain = "WSL:Ubuntu" |
| 9 | |
| 10 | -- window config |
| 11 | config.font = wezterm.font("Hack Nerd Font") |
| 12 | config.font_size = 11.0 |
| 13 | config.window_decorations = "RESIZE" |
| 14 | config.window_background_opacity = 0.85 |
| 15 | config.enable_scroll_bar = true |
| 16 | config.colors = { |
| 17 | scrollbar_thumb = "grey", |
| 18 | } |
| 19 | config.color_scheme = "Tokyo Night Storm" |
| 20 | |
| 21 | -- keymap |
| 22 | config.keys = { |
| 23 | -- pane keys |
| 24 | { key = "h", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Left") }, |
| 25 | { key = "j", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Down") }, |
| 26 | { key = "k", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Up") }, |
| 27 | { key = "l", mods = "CTRL|SHIFT", action = act.ActivatePaneDirection("Right") }, |
| 28 | { key = "h", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Left", 3 }) }, |
| 29 | { key = "j", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Down", 3 }) }, |
| 30 | { key = "k", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Up", 3 }) }, |
| 31 | { key = "l", mods = "CTRL|SHIFT|ALT", action = act.AdjustPaneSize({ "Right", 3 }) }, |
| 32 | { key = "e", mods = "CTRL|SHIFT", action = act.CloseCurrentPane({ confirm = false }) }, |
| 33 | |
| 34 | -- tab keys |
| 35 | { key = "q", mods = "CTRL|ALT", action = act.CloseCurrentTab({ confirm = false }) }, |
| 36 | |
| 37 | -- window keys |
| 38 | { key = "n", mods = "CTRL|ALT", action = utils.SpawnMaximizedCommandInNewWindow({}) }, |
| 39 | |
| 40 | -- debug |
| 41 | { key = "d", mods = "CTRL|SHIFT", action = act.ShowDebugOverlay }, |
| 42 | |
| 43 | -- quit all |
| 44 | { key = "q", mods = "CTRL|SHIFT", action = act.QuitApplication }, |
| 45 | |
| 46 | -- Show the launcher in fuzzy selection mode and have it list all workspaces |
| 47 | -- and allow activating one. |
| 48 | { |
| 49 | key = "9", |
| 50 | mods = "ALT", |
| 51 | action = act.ShowLauncherArgs({ |
| 52 | flags = "FUZZY|WORKSPACES", |
| 53 | }), |
| 54 | }, |
| 55 | { key = "n", mods = "ALT", action = act.SwitchWorkspaceRelative(1) }, |
| 56 | { key = "p", mods = "ALT", action = act.SwitchWorkspaceRelative(-1) }, |
| 57 | -- Prompt for a name to use for a new workspace and switch to it. |
| 58 | { |
| 59 | key = "w", |
| 60 | mods = "CTRL|SHIFT", |
| 61 | action = act.PromptInputLine({ |
| 62 | description = wezterm.format({ |
| 63 | { Attribute = { Intensity = "Bold" } }, |
| 64 | { Foreground = { AnsiColor = "Fuchsia" } }, |
| 65 | { Text = "Enter name for new workspace" }, |
| 66 | }), |
| 67 | action = wezterm.action_callback(function(window, pane, line) |
| 68 | -- line will be `nil` if they hit escape without entering anything |
| 69 | -- An empty string if they just hit enter |
| 70 | -- Or the actual line of text they wrote |
| 71 | if line then |
| 72 | window:perform_action( |
| 73 | act.SwitchToWorkspace({ |
| 74 | name = line, |
| 75 | }), |
| 76 | pane |
| 77 | ) |
| 78 | end |
| 79 | end), |
| 80 | }), |
| 81 | }, |
| 82 | |
| 83 | -- open lazygit |
| 84 | { |
| 85 | key = "g", |
| 86 | mods = "CTRL|SHIFT", |
| 87 | action = utils.SpawnMaximizedCommandInNewWindow({ "lazygit" }), |
| 88 | }, |
| 89 | } |
| 90 | |
| 91 | -- plugins |
| 92 | local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") |
| 93 | tabline.setup() |
| 94 | tabline.apply_to_config(config) |
| 95 | |
| 96 | -- log success on reload |
| 97 | wezterm.on("window-config-reloaded", function(_, _) |
| 98 | wezterm.log_info("Successfully loaded config from .config") |
| 99 | end) |
| 100 | |
| 101 | -- load workspaces |
| 102 | local workspaces = require("workspaces") |
| 103 | workspaces.setup(config) |
| 104 | |
| 105 | return config |