### Configure Platform-Specific Launch Menu Source: https://context7.com/qiansong1/wezterm-config/llms.txt Detects the host operating system to provide tailored shell options and launch menu entries. It supports Windows, macOS, and Linux, ensuring the correct shell binaries are used for each platform. ```lua local platform = require("utils.platform")() local options = { default_prog = {}, launch_menu = {}, } if platform.is_win then options.default_prog = { "powershell" } options.launch_menu = { { label = " PowerShell v1", args = { "powershell" } }, { label = " PowerShell v7", args = { "pwsh" } }, { label = " Cmd", args = { "cmd" } }, { label = " Nushell", args = { "nu" } }, { label = " GitBash", args = { "C:\\soft\\Git\\bin\\bash.exe" } }, { label = " AlmaLinux", args = { "ssh", "kali@192.168.44.147", "-p", "22" } }, } elseif platform.is_mac then options.default_prog = { "/opt/homebrew/bin/fish", "--login" } options.launch_menu = { { label = " Bash", args = { "bash", "--login" } }, { label = " Fish", args = { "/opt/homebrew/bin/fish", "--login" } }, { label = " Nushell", args = { "/opt/homebrew/bin/nu", "--login" } }, { label = " Zsh", args = { "zsh", "--login" } }, } elseif platform.is_linux then options.default_prog = { "bash", "--login" } options.launch_menu = { { label = " Bash", args = { "bash", "--login" } }, { label = " Fish", args = { "/opt/homebrew/bin/fish", "--login" } }, { label = " Nushell", args = { "/opt/homebrew/bin/nu", "--login" } }, { label = " Zsh", args = { "zsh", "--login" } }, } end return options ``` -------------------------------- ### Detect Operating System using WezTerm Target Triple Source: https://context7.com/qiansong1/wezterm-config/llms.txt This Lua utility detects the current operating system (Windows, macOS, Linux) by inspecting WezTerm's target triple string. It provides boolean flags for each platform, allowing for platform-specific configurations within WezTerm. ```lua -- utils/platform.lua local wezterm = require("wezterm") local function is_found(str, pattern) return string.find(str, pattern) ~= nil end local function platform() return { is_win = is_found(wezterm.target_triple, "windows"), is_linux = is_found(wezterm.target_triple, "linux"), is_mac = is_found(wezterm.target_triple, "apple"), } end -- Usage example local p = platform() if p.is_win then -- Windows-specific configuration elseif p.is_mac then -- macOS-specific configuration elseif p.is_linux then -- Linux-specific configuration end return platform ``` -------------------------------- ### Config Class: Lua Configuration Builder Source: https://context7.com/qiansong1/wezterm-config/llms.txt Implements a fluent builder pattern for WezTerm configuration using Lua. The `Config` class allows chaining configuration modules and includes duplicate option detection with warnings. It initializes an empty options table and returns the configuration options. ```lua -- config/init.lua local wezterm = require("wezterm") --- --@class Config --@field options table local Config = {} --- --Initialize Config --@return Config function Config:init() local o = {} self = setmetatable(o, { __index = Config }) self.options = {} return o end --- --Append to `Config.options` --@param new_options table new options to append --@return Config function Config:append(new_options) for k, v in pairs(new_options) do if self.options[k] ~= nil then wezterm.log_warn( 'Duplicate config option detected: ', { old = self.options[k], new = new_options[k] } ) goto continue end self.options[k] = v ::continue:: end return self end -- Usage in wezterm.lua - Main entry point local Config = require("config") require("events.right-status").setup() require("events.tab-title").setup() require("events.new-tab-button").setup() return Config:init() :append(require("config.appearance")) :append(require("config.bindings")) :append(require("config.domains")) :append(require("config.fonts")) :append(require("config.general")) :append(require("config.launch")).options ``` -------------------------------- ### Configure SSH, WSL, and Unix Domains in WezTerm Source: https://context7.com/qiansong1/wezterm-config/llms.txt Defines remote connection settings including SSH hosts, WSL distributions, and Unix domain sockets. It allows for custom authentication, identity files, and default shell programs for specific environments. ```lua return { ssh_domains = { { multiplexing = "None", name = "Kali-linux", remote_address = "192.168.44.147:22", username = "kali", ssh_option = { identityfile = "C:\\Users\\Fizz\\.ssh\\id_rsa", }, }, { multiplexing = "None", name = "Alma-linux", remote_address = "host.myalmalinux.com:22", username = "attacker", ssh_option = { identityfile = "C:\\Users\\Fizz\\.ssh\\id_rsa", }, }, }, unix_domains = {}, wsl_domains = { { name = "WSL:Ubuntu", distribution = "Ubuntu", username = "kevin", default_cwd = "/home/kevin", default_prog = { "fish" }, }, }, } ``` -------------------------------- ### Appearance Configuration: Lua for WezTerm Visuals Source: https://context7.com/qiansong1/wezterm-config/llms.txt Configures the visual appearance of WezTerm, including color schemes, background images, gradients, scrollbar settings, tab bar appearance, cursor style, and window decorations. It supports WebGPU rendering for smooth animations. ```lua -- config/appearance.lua local wezterm = require("wezterm") return { -- Rendering settings term = "xterm-256color", animation_fps = 60, max_fps = 60, front_end = "WebGpu", webgpu_power_preference = "HighPerformance", -- Color scheme color_scheme = "Gruvbox dark, medium (base16)", -- Background with gradient and image overlay window_background_opacity = 1.00, win32_system_backdrop = "Acrylic", window_background_gradient = { colors = { "#1D261B", "#261A25" }, orientation = { Linear = { angle = -45.0 } }, }, background = { { source = { File = wezterm.config_dir .. "/backdrops/space.jpg" }, }, { source = { Color = "#1A1B26" }, height = "100%", width = "100%", opacity = 0.95, }, }, -- Scrollbar enable_scroll_bar = true, min_scroll_bar_height = "3cell", colors = { scrollbar_thumb = "#34354D", }, -- Tab bar enable_tab_bar = true, hide_tab_bar_if_only_one_tab = false, use_fancy_tab_bar = true, tab_max_width = 25, show_tab_index_in_tab_bar = true, switch_to_last_active_tab_when_closing_tab = true, -- Cursor default_cursor_style = "BlinkingBlock", cursor_blink_ease_in = "Constant", cursor_blink_ease_out = "Constant", cursor_blink_rate = 700, -- Window settings adjust_window_size_when_changing_font_size = false, window_decorations = "INTEGRATED_BUTTONS|RESIZE", integrated_title_button_style = "Windows", initial_cols = 120, initial_rows = 24, window_padding = { left = 5, right = 10, top = 12, bottom = 7, }, window_close_confirmation = "AlwaysPrompt", window_frame = { active_titlebar_bg = "#0F2536", inactive_titlebar_bg = "#0F2536", }, } ``` -------------------------------- ### Configure WezTerm Key and Mouse Bindings Source: https://context7.com/qiansong1/wezterm-config/llms.txt This Lua script defines platform-specific modifier keys and assigns them to various terminal actions such as tab management, pane navigation, and font scaling. It also includes modal key tables for resizing and custom mouse event handling for links and text selection. ```lua -- config/bindings.lua local wezterm = require("wezterm") local platform = require("utils.platform")() local act = wezterm.action -- Platform-specific modifier keys local mod = {} if platform.is_mac then mod.SUPER = "SUPER" mod.SUPER_REV = "SUPER|CTRL" elseif platform.is_win or platform.is_linux then mod.SUPER = "ALT" mod.SUPER_REV = "ALT|CTRL" end local keys = { { key = "F1", mods = "NONE", action = "ActivateCopyMode" }, { key = "F2", mods = "NONE", action = act.ActivateCommandPalette }, { key = "c", mods = "CTRL|SHIFT", action = act.CopyTo("Clipboard") }, { key = "t", mods = mod.SUPER, action = act.SpawnTab("DefaultDomain") }, { key = "k", mods = mod.SUPER_REV, action = act.ActivatePaneDirection("Up") }, { key = "r", mods = mod.SUPER, action = act.ResetFontSize }, } local key_tables = { resize_font = { { key = "k", action = act.IncreaseFontSize }, { key = "Escape", action = "PopKeyTable" }, } } local mouse_bindings = { { event = { Up = { streak = 1, button = "Left" } }, mods = "CTRL", action = act.OpenLinkAtMouseCursor }, } return { disable_default_key_bindings = true, disable_default_mouse_bindings = true, leader = { key = "Space", mods = "CTRL|SHIFT" }, keys = keys, key_tables = key_tables, mouse_bindings = mouse_bindings } ``` -------------------------------- ### Configure General Terminal Behavior and Hyperlink Rules Source: https://context7.com/qiansong1/wezterm-config/llms.txt Manages global settings such as auto-reload, scrollback buffer, and paste behavior. Additionally, it defines regex-based rules for identifying and formatting hyperlinks and email addresses in terminal output. ```lua return { automatically_reload_config = true, check_for_updates = false, exit_behavior = "CloseOnCleanExit", status_update_interval = 1000, scrollback_lines = 5000, canonicalize_pasted_newlines = "CarriageReturn", hyperlink_rules = { { regex = "\\((\\w+://\\S+)\\)", format = "$1", highlight = 1 }, { regex = "\\[(\\w+://\\S+)\\]", format = "$1", highlight = 1 }, { regex = "\\{(\\w+://\\S+)\\}", format = "$1", highlight = 1 }, { regex = "<(\\w+://\\S+)>", format = "$1", highlight = 1 }, { regex = "\\b\\w+://\\S+[)/a-zA-Z0-9-]+", format = "$0" }, { regex = "\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b", format = "mailto:$0" }, }, } ``` -------------------------------- ### Display Date, Time, and Battery Info in Right Status Bar (Lua) Source: https://context7.com/qiansong1/wezterm-config/llms.txt This Lua module configures the WezTerm right status bar to display the current date and time, along with battery information. It uses customizable icons for battery status (charging/discharging) and charge level. Dependencies include the 'wezterm' module and a 'utils.math' module for clamping and rounding. ```lua local wezterm = require("wezterm") local math = require("utils.math") local M = {} M.separator_char = " ~ " M.colors = { date_fg = "#3E7FB5", date_bg = "#0F2536", battery_fg = "#B52F90", battery_bg = "#0F2536", separator_fg = "#786D22", separator_bg = "#0F2536", } M.cells = {} M.push = function(text, icon, fg, bg, separate) table.insert(M.cells, { Foreground = { Color = fg } }) table.insert(M.cells, { Background = { Color = bg } }) table.insert(M.cells, { Attribute = { Intensity = "Bold" } }) table.insert(M.cells, { Text = icon .. " " .. text .. " " }) if separate then table.insert(M.cells, { Foreground = { Color = M.colors.separator_fg } }) table.insert(M.cells, { Background = { Color = M.colors.separator_bg } }) table.insert(M.cells, { Text = M.separator_char }) end table.insert(M.cells, "ResetAttributes") end M.set_date = function() local date = wezterm.strftime(" %a %H:%M") M.push(date, "", M.colors.date_fg, M.colors.date_bg, true) end M.set_battery = function() local discharging_icons = { "󰂃", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹" } local charging_icons = { "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅" } for _, b in ipairs(wezterm.battery_info()) do local idx = math.clamp(math.round(b.state_of_charge * 10), 1, 10) local charge = string.format("%.0f%%", b.state_of_charge * 100) local icon = b.state == "Charging" and charging_icons[idx] or discharging_icons[idx] M.push(charge, icon, M.colors.battery_fg, M.colors.battery_bg, false) end end M.setup = function() wezterm.on("update-right-status", function(window, _pane) M.cells = {} M.set_date() M.set_battery() window:set_right_status(wezterm.format(M.cells)) end) end return M ``` -------------------------------- ### Configure Font and Rendering Settings Source: https://context7.com/qiansong1/wezterm-config/llms.txt Sets the terminal font family and size, with logic to adjust size based on the platform. It also configures FreeType rendering targets for text clarity. ```lua local wezterm = require("wezterm") local platform = require("utils.platform") local font = "JetBrainsMono NF" local font_size = platform().is_mac and 12 or 9 return { font = wezterm.font(font), font_size = font_size, freetype_load_target = "Normal", freetype_render_target = "Normal", } ``` -------------------------------- ### Format Custom Tab Titles with Process Name and Indicators (Lua) Source: https://context7.com/qiansong1/wezterm-config/llms.txt This Lua module formats custom tab titles in WezTerm. It displays process names, admin indicators, unseen output alerts, and styled semi-circle decorations. It handles different tab states (active, hover, default) with distinct color schemes. Dependencies include the 'wezterm' module. ```lua local wezterm = require("wezterm") local GLYPH_SEMI_CIRCLE_LEFT = "" local GLYPH_SEMI_CIRCLE_RIGHT = "" local GLYPH_CIRCLE = "󰇷 " local GLYPH_ADMIN = "󰖳 " local M = {} M.cells = {} M.colors = { default = { bg = "#8C246F", fg = "#0F2536" }, is_active = { bg = "#3A854B", fg = "#0F2536" }, hover = { bg = "#8C246F", fg = "#0F2536" }, } M.set_process_name = function(s) local a = string.gsub(s, "(.*[/\])(.*)", "%2") return a:gsub("%.exe$", "") end M.set_title = function(process_name, static_title, active_title, max_width, inset) local title inset = inset or 6 if process_name:len() > 0 and static_title:len() == 0 then title = " " .. process_name .. " ~ " .. " " elseif static_title:len() > 0 then title = "󰌪 " .. static_title .. " ~ " .. " " else title = "󰌽 " .. active_title .. " ~ " .. " " end if title:len() > max_width - inset then local diff = title:len() - max_width + inset title = wezterm.truncate_right(title, title:len() - diff) end return title end M.push = function(bg, fg, attribute, text) table.insert(M.cells, { Background = { Color = bg } }) table.insert(M.cells, { Foreground = { Color = fg } }) table.insert(M.cells, { Attribute = attribute }) table.insert(M.cells, { Text = text }) end M.setup = function() wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width) M.cells = {} local bg, fg local process_name = M.set_process_name(tab.active_pane.foreground_process_name) local is_admin = M.check_if_admin(tab.active_pane.title) -- Assuming check_if_admin is defined elsewhere local title = M.set_title(process_name, tab.tab_title, tab.active_pane.title, max_width) if tab.is_active then bg, fg = M.colors.is_active.bg, M.colors.is_active.fg elseif hover then bg, fg = M.colors.hover.bg, M.colors.hover.fg else bg, fg = M.colors.default.bg, M.colors.default.fg end -- Check for unseen output in any pane local has_unseen_output = false for _, pane in ipairs(tab.panes) do if pane.has_unseen_output then has_unseen_output = true break end end M.push(fg, bg, { Intensity = "Bold" }, GLYPH_SEMI_CIRCLE_LEFT) if is_admin then M.push(bg, fg, { Intensity = "Bold" }, " " .. GLYPH_ADMIN) end M.push(bg, fg, { Intensity = "Bold" }, " " .. title) if has_unseen_output then M.push(bg, "#FF3B8B", { Intensity = "Bold" }, " " .. GLYPH_CIRCLE) end M.push(bg, fg, { Intensity = "Bold" }, " ") M.push(fg, bg, { Intensity = "Bold" }, GLYPH_SEMI_CIRCLE_RIGHT) return M.cells end) end return M ``` -------------------------------- ### Define Custom Catppuccin Mocha Color Scheme for WezTerm Source: https://context7.com/qiansong1/wezterm-config/llms.txt This Lua module defines a custom color scheme based on Catppuccin Mocha, tailored for WezTerm. It specifies colors for terminal text, background, cursor, selection, ANSI/brights, and tab bar elements, enhancing terminal aesthetics. ```lua -- colors/custom.lua local mocha = { rosewater = "#f5e0dc", flamingo = "#f2cdcd", pink = "#f5c2e7", mauve = "#cba6f7", red = "#f38ba8", maroon = "#eba0ac", peach = "#fab387", yellow = "#f9e2af", green = "#a6e3a1", teal = "#94e2d5", sky = "#89dceb", sapphire = "#74c7ec", blue = "#89b4fa", lavender = "#b4befe", text = "#cdd6f4", base = "#1f1f28", mantle = "#181825", crust = "#11111b", } local colorscheme = { foreground = mocha.text, background = mocha.base, cursor_bg = mocha.rosewater, cursor_fg = mocha.crust, selection_bg = mocha.surface2, ansi = { "#0C0C0C", "#C50F1F", "#13A10E", "#C19C00", "#0037DA", "#881798", "#3A96DD", "#CCCCCC", }, brights = { "#767676", "#E74856", "#16C60C", "#F9F1A5", "#3B78FF", "#B4009E", "#61D6D6", "#F2F2F2", }, tab_bar = { background = "#000000", active_tab = { bg_color = mocha.surface2, fg_color = mocha.text }, inactive_tab = { bg_color = mocha.surface0, fg_color = mocha.subtext1 }, }, } return colorscheme ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.