Created
March 6, 2026 23:30
-
-
Save madrang/6ce29e71b2a6336cac18e5cf399c342a to your computer and use it in GitHub Desktop.
Wezterm Config
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
| local wezterm = require("wezterm") -- Pull in the wezterm API | |
| local config = wezterm.config_builder() -- This will hold the configuration. | |
| -- Spawn a fish shell in login mode | |
| config.default_prog = { "/usr/bin/fish", "-l" } | |
| config.font = wezterm.font_with_fallback({ | |
| "JetBrains Mono" | |
| , "Noto Color Emoji" -- Assumed to have Emoji Presentation | |
| , "Symbols Nerd Font Mono" | |
| }) | |
| config.font_size = 16 | |
| config.line_height = 1 | |
| --config.use_fancy_tab_bar = false | |
| --config.enable_tab_bar = false | |
| config.use_dead_keys = true | |
| --config.hide_tab_bar_if_only_one_tab = true | |
| config.window_decorations = "RESIZE" | |
| config.window_background_opacity = 1 | |
| --config.initial_cols = 120 | |
| --config.initial_rows = 28 | |
| -- https://wezterm.org/colorschemes/index.html | |
| --config.color_scheme = "Wryan" | |
| --config.color_scheme = "Count Von Count (terminal.sexy)" | |
| --config.color_scheme = "Lost Woods (terminal.sexy)" | |
| --config.color_scheme = "DimmedMonokai" | |
| --config.color_scheme = "Hacktober" | |
| --config.color_scheme = "Nudge (terminal.sexy)" | |
| --config.color_scheme = "Neopolitan" | |
| config.color_scheme = "Nancy (terminal.sexy)" | |
| config.visual_bell = { | |
| fade_in_function = "EaseIn", fade_in_duration_ms = 150 | |
| , fade_out_function = "EaseOut", fade_out_duration_ms = 150 | |
| , target = "CursorColor" | |
| } | |
| config.leader = { key = "#", mods = "CTRL", timeout_milliseconds = 1000 } | |
| config.keys = { | |
| -- Basic Actions -- | |
| { action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }) | |
| , mods = "LEADER|SHIFT", key = "|" | |
| } | |
| , { action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }) | |
| , mods = "LEADER|CTRL", key = "#" | |
| } | |
| -- Close Tab | |
| , { action = wezterm.action.CloseCurrentPane({ confirm = true }) | |
| , mods = "CTRL|SHIFT", key = "W" | |
| } | |
| -- Create Workspace from name prompt | |
| , { action = wezterm.action.PromptInputLine({ | |
| description = wezterm.format({ | |
| { Attribute = { Intensity = "Bold" } } | |
| , { Foreground = { AnsiColor = "Fuchsia" } } | |
| , { Text = "Enter name for new workspace" } | |
| }) | |
| , action = wezterm.action_callback( | |
| function(window, pane, line) | |
| -- line will be `nil` if they hit escape without entering anything, an empty string if they just hit enter or the actual line of text they wrote. | |
| if line then | |
| window:perform_action( | |
| wezterm.action.SwitchToWorkspace({ name = line }) | |
| , pane | |
| ) | |
| end | |
| end) | |
| }) | |
| , mods = "CTRL|SHIFT", key = "M" | |
| } | |
| -- Rename Tab | |
| , { action = wezterm.action.PromptInputLine({ description = "Enter new name for tab" | |
| , initial_value = "" | |
| , action = wezterm.action_callback( | |
| function(window, pane, line) | |
| -- line will be `nil` if they hit escape without entering anything, an empty string if they just hit enter or the actual line of text they wrote. | |
| if line then | |
| window:active_tab():set_title(line) | |
| end | |
| end) | |
| }) | |
| , mods = "CTRL|SHIFT", key = "E" | |
| } | |
| -- Launchers -- | |
| , { action = wezterm.action.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES|TABS" }) | |
| , mods = "SHIFT|CTRL", key = ">" | |
| } | |
| } | |
| config.launch_menu = { | |
| { | |
| args = { "top" } | |
| } | |
| , { label = "NetStat" | |
| --, cwd = "/some/path" | |
| --, set_environment_variables = { FOO = "bar" } | |
| , args = { "bash", "-c", "netstat -tupan ; read -n 1 -s -r -p \"Press any key to continue\"" } | |
| } | |
| } | |
| local mux = wezterm.mux | |
| wezterm.on("gui-startup", function(cmd) -- https://wezfurlong.org/wezterm/config/lua/gui-events/gui-startup.html | |
| local args = {} | |
| if cmd and cmd.args then | |
| args = cmd.args | |
| end | |
| local tab, pane, window = mux.spawn_window({ -- Create the window as a btop system monitor viewer. | |
| workspace = "SysMon" | |
| , cwd = wezterm.home_dir | |
| , args = { "btop" } | |
| }) | |
| local tab, pane = window:spawn_tab({ -- Add iftop as a new tab. | |
| cwd = wezterm.home_dir | |
| , args = { "iftop" } | |
| }) | |
| tab:set_title("iftop") | |
| window:gui_window():maximize() -- Maximize GUI | |
| wezterm.sleep_ms(33) -- Wait for maximize animation to complete... | |
| local tab, pane, window = mux.spawn_window({ -- Create the default workspace in its own window. | |
| workspace = "Default" | |
| , cwd = wezterm.home_dir | |
| , args = args | |
| }) | |
| mux.set_active_workspace("Default") | |
| local new_pane = pane:split({ | |
| direction = "Top" | |
| , size = 0.6 | |
| , cwd = wezterm.home_dir | |
| }) | |
| end) | |
| -- The utf8 character for the "powerline" left facing solid arrow. | |
| local ARROW_SOLID_LEFT = "\u{e0b2}" | |
| local ARROW_SOLID_RIGHT = "\u{e0b0}" | |
| local ARROW_THIN_LEFT = "\u{e0b1}" | |
| local ARROW_THIN_RIGHT = "\u{e0b3}" | |
| local nf = wezterm.nerdfonts | |
| local GLYPH_SEMI_CIRCLE_LEFT = nf.ple_left_half_circle_thick | |
| local GLYPH_SEMI_CIRCLE_RIGHT = nf.ple_right_half_circle_thick | |
| local GLYPH_KEY_TABLE = nf.md_table_key | |
| local GLYPH_KEY = nf.md_key | |
| local ICON_SEPARATOR = nf.oct_dash | |
| local ICON_DATE = nf.fa_calendar | |
| ---@type string[] | |
| local discharging_icons = { | |
| nf.md_battery_10 | |
| , nf.md_battery_20 | |
| , nf.md_battery_30 | |
| , nf.md_battery_40 | |
| , nf.md_battery_50 | |
| , nf.md_battery_60 | |
| , nf.md_battery_70 | |
| , nf.md_battery_80 | |
| , nf.md_battery_90 | |
| , nf.md_battery | |
| } | |
| ---@type string[] | |
| local charging_icons = { | |
| nf.md_battery_charging_10 | |
| , nf.md_battery_charging_20 | |
| , nf.md_battery_charging_30 | |
| , nf.md_battery_charging_40 | |
| , nf.md_battery_charging_50 | |
| , nf.md_battery_charging_60 | |
| , nf.md_battery_charging_70 | |
| , nf.md_battery_charging_80 | |
| , nf.md_battery_charging_90 | |
| , nf.md_battery_charging | |
| } | |
| ---@type table<string, Cells.SegmentColors> | |
| local colors = { | |
| date = { bg = "rgba(0, 0, 0, 0.4)", fg = "#fab387" } | |
| , battery = { bg = "rgba(0, 0, 0, 0.4)", fg = "#f9e2af" } | |
| , scircle = { bg = "rgba(0, 0, 0, 0.4)", fg = "#fab387" } | |
| , separator = { bg = "rgba(0, 0, 0, 0.4)", fg = "#74c7ec" } | |
| } | |
| local function clamp(x, min, max) | |
| return x < min and min or (x > max and max or x) | |
| end | |
| local function round(x, increment) | |
| if increment then | |
| return round(x / increment) * increment | |
| end | |
| return x >= 0 and math.floor(x + 0.5) or math.ceil(x - 0.5) | |
| end | |
| ---@return string -- ๐ ##.#% | |
| local function battery_info() -- ref: https://wezfurlong.org/wezterm/config/lua/wezterm/battery_info.html | |
| local charge = 0 | |
| local battery_count = 0 | |
| local last_state = nil | |
| for _, b in ipairs(wezterm.battery_info()) do | |
| charge = charge + b.state_of_charge | |
| battery_count = 1 + battery_count | |
| last_state = b.state | |
| end | |
| if battery_count <= 0 then | |
| return "" | |
| end | |
| charge = charge / battery_count | |
| local icon = "" | |
| local idx = clamp(round(charge * 10), 1, 10) | |
| if last_state == "Charging" then | |
| icon = charging_icons[idx] | |
| else | |
| icon = discharging_icons[idx] | |
| end | |
| return icon, string.format("%.0f%%", charge * 100) | |
| end | |
| wezterm.on("update-status", function(window, pane) | |
| local color_scheme = window:effective_config().resolved_palette | |
| local bg = color_scheme.background | |
| local fg = color_scheme.foreground | |
| local panel_mode = "" | |
| local active_key_table = window:active_key_table() | |
| if active_key_table then | |
| panel_mode = panel_mode .. active_key_table | |
| end | |
| if window:leader_is_active() then | |
| panel_mode = "Leader!" | |
| end | |
| if not panel_mode or string.len(panel_mode) == 0 then | |
| panel_mode = window:active_workspace() | |
| end | |
| window:set_left_status(wezterm.format({ | |
| -- Left status text | |
| { Background = { Color = bg } } | |
| , { Foreground = { Color = fg } } | |
| , { Text = " " | |
| .. panel_mode | |
| .. " " | |
| } | |
| -- Draw the right facing arrow | |
| , { Background = { Color = "none" } } | |
| , { Foreground = { Color = bg } } | |
| , { Text = ARROW_SOLID_RIGHT } | |
| })) | |
| local date = wezterm.strftime("%a %b %-d %H:%M") -- "Wed Mar 3 08:14" | |
| local bat_icon, bat_text = battery_info() -- ๐, ##.#% | |
| window:set_right_status(wezterm.format({ | |
| -- Draw the left facing arrow | |
| { Background = { Color = "none" } } | |
| , { Foreground = { Color = bg } } | |
| , { Text = ARROW_SOLID_LEFT } | |
| -- Right status text | |
| , { Background = { Color = bg } } | |
| , { Foreground = { Color = fg } } | |
| , { Text = " " | |
| .. ICON_DATE .. " " .. date .. " " | |
| .. ICON_SEPARATOR .. " " | |
| .. bat_icon .. " " .. bat_text .. " " | |
| } | |
| })) | |
| end) | |
| wezterm.on("augment-command-palette", function(window, pane) | |
| return { | |
| { brief = "Take screenshot" | |
| , icon = "cod_device_camera" | |
| , action = wezterm.action.PromptInputLine( | |
| { description = "Screenshot name" | |
| , initial_value = "/tmp/term_scr" | |
| , action = wezterm.action_callback(function(window, pane, line) | |
| if line then | |
| local fileOut = io.open(line .. ".txt", "w+") | |
| local dimensions = pane:get_dimensions() | |
| fileOut:write("\x1b[8;" .. dimensions.viewport_rows .. ";" .. dimensions.cols .. "t") | |
| fileOut:write("\x1b]0;" .. pane:get_title() .. "\x1b\\") | |
| --local theme = wezterm.get_builtin_color_schemes()[window:effective_config().color_scheme] | |
| --theme = { | |
| -- palette = table.concat(append_tables(theme.ansi, theme.brights), ':') | |
| -- , fg = theme.foreground | |
| -- , bg = theme.background | |
| --} | |
| fileOut:write(pane:get_lines_as_escapes()) | |
| fileOut:flush() | |
| fileOut:close() | |
| --window:perform_action( | |
| -- wezterm.action.SpawnCommandInNewWindow({ args = { "python3", "~/Projects/termScrConverter.py", line .. ".txt" }}) | |
| -- , pane | |
| --) | |
| --pane:send_text("python3 ~/Projects/termScrConverter.py --delete \"" .. line .. ".txt\"\n") | |
| end | |
| end)} | |
| )} | |
| } | |
| end) | |
| return config -- and finally, return the configuration to wezterm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment