### Complete bar.wezterm Configuration Example Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt This example demonstrates a full configuration for the bar.wezterm plugin, including setting the color scheme, leader key, and various modules like tabs, workspace, zoom, and clock. Ensure 'color_scheme' is set before applying bar.wezterm. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() -- Must set color_scheme before applying bar.wezterm config.color_scheme = "Catppuccin Mocha" -- Optional: Set leader key for workspace indicator config.leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1000 } local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { position = "bottom", max_width = 36, padding = { left = 1, right = 1, tabs = { left = 0, right = 2 }, }, separator = { space = 1, left_icon = wezterm.nerdfonts.fa_long_arrow_right, right_icon = wezterm.nerdfonts.fa_long_arrow_left, field_icon = wezterm.nerdfonts.indent_line, }, modules = { tabs = { active_tab_fg = 4, active_tab_bg = "transparent", inactive_tab_fg = 6, inactive_tab_bg = "transparent", new_tab_fg = 2, new_tab_bg = "transparent", }, workspace = { enabled = true, icon = wezterm.nerdfonts.cod_window, color = 8 }, leader = { enabled = true, icon = wezterm.nerdfonts.oct_rocket, color = 2 }, zoom = { enabled = true, icon = wezterm.nerdfonts.md_fullscreen, color = 4 }, pane = { enabled = true, icon = wezterm.nerdfonts.cod_multiple_windows, color = 7 }, username = { enabled = false }, -- Disable username display hostname = { enabled = false }, -- Disable hostname display clock = { enabled = true, icon = wezterm.nerdfonts.md_calendar_clock, format = "%H:%M", color = 5 }, cwd = { enabled = true, icon = wezterm.nerdfonts.oct_file_directory, color = 7 }, ssh = { enabled = true, icon = wezterm.nerdfonts.md_ssh, color = 5 }, spotify = { enabled = false }, -- Keep Spotify disabled }, }) return config ``` -------------------------------- ### Enable Spotify Module in bar.wezterm Source: https://github.com/adriankarlen/bar.wezterm/blob/main/README.md Example of enabling the Spotify module by passing an options table to the apply_to_config function. ```lua -- example enable spotify module bar.apply_to_config( config, { modules = { spotify = { enabled = true, }, }, } ) ``` -------------------------------- ### Lua Type Annotation Example Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Example of Lua type annotations using EmmyLua style for class definitions and function parameters/return values. Use ---@private for internal modules. ```lua --- --@class option.module ---@field enabled boolean ---@field icon string ---@field color number --get basename for dir/file, removing extension and path ---@param s string ---@return string? ---@return number? H._basename = function(s) ... end ``` ```lua --- --@private ---@class bar.tabs local M = {} ``` -------------------------------- ### Install bar.wezterm Plugin Source: https://github.com/adriankarlen/bar.wezterm/blob/main/README.md Import the bar.wezterm plugin and apply it to your wezterm configuration. Ensure this is called after the color scheme is set. ```lua local bar = wezterm.plugin.require("https://github.com/adriankarlen/bar.wezterm") bar.apply_to_config(config) ``` -------------------------------- ### Configure Spotify Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables Spotify integration to display the currently playing song. Requires spotify-tui to be installed and configured. Includes throttling to limit API calls. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Catppuccin Frappe" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { spotify = { enabled = true, -- Enable Spotify integration icon = wezterm.nerdfonts.fa_spotify, color = 3, -- ANSI yellow/green (Spotify color) max_width = 64, -- Maximum width for song info throttle = 15, -- Seconds between Spotify API calls }, }, }) return config ``` -------------------------------- ### Check for Windows and Normalize Paths Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Use this code to detect if the operating system is Windows and to normalize path separators to forward slashes for consistency across different platforms. It attempts to get the user profile or home directory. ```lua H.is_windows = package.config:sub(1, 1) == "\\" H.home = (os.getenv "USERPROFILE" or os.getenv "HOME" or wez.home_dir or ""):gsub("\\", "/") ``` -------------------------------- ### Configure Tab Colors in bar.wezterm Source: https://github.com/adriankarlen/bar.wezterm/blob/main/README.md Customize tab foreground and background colors using ANSI color indices or hex color strings. This example shows setting active tab colors. ```lua bar.apply_to_config(config, { modules = { tabs = { active_tab_fg = 1, active_tab_bg = 6, -- ansi color index -- or use a hex color: -- active_tab_bg = "#c6a0f6", }, }, }) ``` -------------------------------- ### Input Validation in Helper Function Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md This Lua example demonstrates guarding against nil or wrong-type inputs at the top of a helper function, returning a safe default value. ```lua H._space = function(s, space, trailing_space) if type(s) ~= "string" or type(space) ~= "number" then return "" end ... end ``` -------------------------------- ### Lua Control Flow with goto Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Demonstrates the 'goto' idiom in Lua for simulating 'continue' behavior within loops. Label names should be descriptive. ```lua for _, item in ipairs(list) do if not condition then goto continue end -- do work ::continue:: end ``` -------------------------------- ### Configure Username and Hostname Modules Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables and configures the username and hostname modules to display in the status bar. Requires WezTerm and the bar plugin. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Gruvbox Dark" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { username = { enabled = true, icon = wezterm.nerdfonts.fa_user, color = 6, -- ANSI cyan }, hostname = { enabled = true, icon = wezterm.nerdfonts.cod_server, color = 8, -- ANSI bright black }, }, }) return config ``` -------------------------------- ### Main API: apply_to_config Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt The main entry point to apply bar.wezterm configuration to your WezTerm config. It merges user options with defaults and registers event handlers. Must be called after setting `color_scheme`. ```APIDOC ## POST /apply_to_config ### Description Applies the bar.wezterm configuration to your WezTerm config object. This function must be called after setting your `color_scheme`. It merges user-provided options with sensible defaults and registers all necessary event handlers for rendering the tab bar. ### Method POST ### Endpoint /apply_to_config ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **config** (object) - Required - The WezTerm configuration object. - **opts** (object) - Optional - User-provided options to customize the tab bar. - **position** (string) - Optional - 'top' or 'bottom'. Defaults to 'bottom'. - **max_width** (number) - Optional - Maximum width of the tab bar. - **padding** (object) - Optional - Padding settings for the tab bar. - **left** (number) - Optional - Left padding. - **right** (number) - Optional - Right padding. - **tabs** (object) - Optional - Padding for tabs. - **left** (number) - Optional - Left padding for tabs. - **right** (number) - Optional - Right padding for tabs. - **separator** (object) - Optional - Separator configuration. - **space** (number) - Optional - Space around the separator. - **left_icon** (string) - Optional - Icon for the left separator. - **right_icon** (string) - Optional - Icon for the right separator. - **field_icon** (string) - Optional - Icon for field separators. - **modules** (object) - Optional - Configuration for various modules. - **tabs** (object) - Optional - Tab module configuration. - **active_tab_fg** (string|number) - Optional - Foreground color for active tabs. - **active_tab_bg** (string) - Optional - Background color for active tabs. - **inactive_tab_fg** (string|number) - Optional - Foreground color for inactive tabs. - **inactive_tab_bg** (string) - Optional - Background color for inactive tabs. - **new_tab_fg** (string|number) - Optional - Foreground color for the new tab button. - **new_tab_bg** (string) - Optional - Background color for the new tab button. - **workspace** (object) - Optional - Workspace module configuration. - **enabled** (boolean) - Optional - Enable workspace module. - **icon** (string) - Optional - Icon for the workspace module. - **color** (string|number) - Optional - Color for the workspace module. - **leader** (object) - Optional - Leader module configuration. - **enabled** (boolean) - Optional - Enable leader module. - **icon** (string) - Optional - Icon for the leader module. - **color** (string|number) - Optional - Color for the leader module. - **zoom** (object) - Optional - Zoom module configuration. - **enabled** (boolean) - Optional - Enable zoom module. - **icon** (string) - Optional - Icon for the zoom module. - **color** (string|number) - Optional - Color for the zoom module. - **pane** (object) - Optional - Pane module configuration. - **enabled** (boolean) - Optional - Enable pane module. - **icon** (string) - Optional - Icon for the pane module. - **color** (string|number) - Optional - Color for the pane module. ### Request Example ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() -- Set your color scheme first (required before apply_to_config) config.color_scheme = "Catppuccin Mocha" -- Import the plugin local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" -- Basic usage with default configuration bar.apply_to_config(config) -- Or with custom options bar.apply_to_config(config, { position = "top", -- "top" or "bottom" max_width = 40, padding = { left = 2, right = 2, tabs = { left = 1, right = 3 }, }, separator = { space = 2, left_icon = wezterm.nerdfonts.fa_long_arrow_right, right_icon = wezterm.nerdfonts.fa_long_arrow_left, field_icon = wezterm.nerdfonts.indent_line, }, modules = { tabs = { active_tab_fg = 4, active_tab_bg = "transparent", inactive_tab_fg = 6, inactive_tab_bg = "transparent", new_tab_fg = "#c6a0f6", new_tab_bg = "transparent", }, workspace = { enabled = true, icon = wezterm.nerdfonts.cod_window, color = 8, }, leader = { enabled = true, icon = wezterm.nerdfonts.oct_rocket, color = 2, }, zoom = { enabled = true, icon = wezterm.nerdfonts.md_fullscreen, color = 4, }, pane = { enabled = true, icon = wezterm.nerdfonts.cod_multiple_windows, color = 7, }, }, }) return config ``` ### Response #### Success Response (200) - **status** (string) - Indicates success. #### Response Example ```json { "status": "Configuration applied successfully" } ``` ``` -------------------------------- ### Format Code with StyLua Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Run this command to format all code in the repository using StyLua. It's the only automated tool and should be run before committing. ```sh stylua . ``` -------------------------------- ### Configure Workspace and Leader Modules Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables and configures the workspace and leader modules to display workspace names and leader key status. The color scheme must be set prior to this configuration. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Catppuccin Mocha" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { workspace = { enabled = true, icon = wezterm.nerdfonts.cod_window, color = 8, -- ANSI bright black }, leader = { enabled = true, icon = wezterm.nerdfonts.oct_rocket, color = 2, -- ANSI green when leader is active }, }, }) return config ``` -------------------------------- ### Standard Lua Module Pattern Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md This Lua code demonstrates the standard module pattern used in the project, including local requires, attaching public API to M, and returning M. ```lua local wez = require "wezterm" local utilities = require "bar.utilities" --- --@private ---@class bar.example local M = {} M.some_function = function(arg) ... end return M ``` -------------------------------- ### Error Handling with pcall Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md This Lua snippet shows how to use pcall to safely call WezTerm APIs that might fail at runtime, returning early on failure. ```lua local present, conf = pcall(window.effective_config, window) if not present then return end ``` -------------------------------- ### Load bar.wezterm Plugin in WezTerm Configuration Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Include this Lua code in your wezterm.lua to load and apply the bar.wezterm plugin. Ensure the path to the plugin is correct. ```lua local bar = wez.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, opts) ``` -------------------------------- ### Configure Zoom Indicator Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables the zoom module to display a fullscreen indicator when a pane is zoomed. The color scheme should be configured before applying this. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Tokyo Night" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { zoom = { enabled = true, -- Enable zoom indicator icon = wezterm.nerdfonts.md_fullscreen, color = 4, -- ANSI blue }, }, }) return config ``` -------------------------------- ### Configure Pane Process Name Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables the pane module to display the foreground process name of the active pane. Ensure your color scheme is set before applying. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Dracula" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { pane = { enabled = true, icon = wezterm.nerdfonts.cod_multiple_windows, color = 7, -- ANSI white }, }, }) return config ``` -------------------------------- ### Apply bar.wezterm with Default Configuration Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Applies the bar.wezterm plugin with its default settings. Ensure your color scheme is set before calling this function. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() -- Set your color scheme first (required before apply_to_config) config.color_scheme = "Catppuccin Mocha" -- Import the plugin local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" -- Basic usage with default configuration bar.apply_to_config(config) return config ``` -------------------------------- ### Configure Tab Colors with bar.wezterm Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Configures the colors for active, inactive, and new tabs using ANSI color indices or hex strings. Set your color scheme before applying the plugin. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Rosé Pine" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { tabs = { active_tab_fg = 4, -- ANSI blue for active tab text active_tab_bg = "transparent", -- No background inactive_tab_fg = 6, -- ANSI cyan for inactive tabs inactive_tab_bg = "transparent", new_tab_fg = "#c6a0f6", -- Hex color for new tab button new_tab_bg = "transparent", }, }, }) return config ``` -------------------------------- ### Default bar.wezterm Configuration Source: https://github.com/adriankarlen/bar.wezterm/blob/main/README.md The default configuration for bar.wezterm, including settings for position, padding, separators, and various modules. Requires a Nerd Font. ```lua local config = { position = "bottom", max_width = 32, padding = { left = 1, right = 1, tabs = { left = 0, right = 2, }, }, separator = { space = 1, left_icon = wez.nerdfonts.fa_long_arrow_right, right_icon = wez.nerdfonts.fa_long_arrow_left, field_icon = wez.nerdfonts.indent_line, }, modules = { tabs = { active_tab_fg = 4, active_tab_bg = "transparent", inactive_tab_fg = 6, inactive_tab_bg = "transparent", new_tab_fg = 2, new_tab_bg = "transparent", }, workspace = { enabled = true, icon = wez.nerdfonts.cod_window, color = 8, }, leader = { enabled = true, icon = wez.nerdfonts.oct_rocket, color = 2, }, zoom = { enabled = false, icon = wez.nerdfonts.md_fullscreen, color = 4, }, pane = { enabled = true, icon = wez.nerdfonts.cod_multiple_windows, color = 7, }, username = { enabled = true, icon = wez.nerdfonts.fa_user, color = 6, }, hostname = { enabled = true, icon = wez.nerdfonts.cod_server, color = 8, }, clock = { enabled = true, icon = wez.nerdfonts.md_calendar_clock, format = "%H:%M", color = 5, }, cwd = { enabled = true, icon = wez.nerdfonts.oct_file_directory, color = 7, }, ssh = { enabled = false, icon = wez.nerdfonts.md_ssh, color = 5, }, spotify = { enabled = false, icon = wez.nerdfonts.fa_spotify, color = 3, max_width = 64, throttle = 15, }, }, } ``` -------------------------------- ### Configure Current Working Directory (cwd) Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables and configures the cwd module to display the current working directory. It abbreviates the home directory and shows the Git repository root name for repositories. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "One Dark" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { cwd = { enabled = true, icon = wezterm.nerdfonts.oct_file_directory, color = 7, -- ANSI white }, }, }) return config ``` -------------------------------- ### Configure Clock Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables and configures the clock module to display the current time with a custom format. Supports various date and time formatting options. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Nord" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { clock = { enabled = true, icon = wezterm.nerdfonts.md_calendar_clock, format = "%Y-%m-%d %H:%M:%S", -- Full date and time -- format = "%H:%M", -- Just hours and minutes (default) -- format = "%I:%M %p", -- 12-hour format with AM/PM color = 5, -- ANSI magenta }, }, }) return config ``` -------------------------------- ### Apply bar.wezterm with Custom Options Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Applies the bar.wezterm plugin with custom options for position, padding, and separators. The color scheme must be set prior to this call. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() -- Set your color scheme first (required before apply_to_config) config.color_scheme = "Catppuccin Mocha" -- Import the plugin local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" -- Or with custom options bar.apply_to_config(config, { position = "top", -- "top" or "bottom" max_width = 40, padding = { left = 2, right = 2, tabs = { left = 1, right = 3 }, }, separator = { space = 2, left_icon = wezterm.nerdfonts.fa_long_arrow_right, right_icon = wezterm.nerdfonts.fa_long_arrow_left, field_icon = wezterm.nerdfonts.indent_line, }, }) return config ``` -------------------------------- ### Configure SSH Detection Module Source: https://context7.com/adriankarlen/bar.wezterm/llms.txt Enables SSH detection in the status bar. When enabled, it automatically hides the `cwd` module for SSH sessions. Disabled by default. ```lua local wezterm = require "wezterm" local config = wezterm.config_builder() config.color_scheme = "Solarized Dark" local bar = wezterm.plugin.require "https://github.com/adriankarlen/bar.wezterm" bar.apply_to_config(config, { modules = { ssh = { enabled = true, -- Enable SSH detection icon = wezterm.nerdfonts.md_ssh, color = 5, -- ANSI magenta }, }, }) return config ``` -------------------------------- ### StyLua Configuration Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md This TOML configuration file defines the code style rules enforced by StyLua, including line endings, indentation, and quote style. ```toml line_endings = "Unix" indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferDouble" call_parentheses = "None" ``` -------------------------------- ### Check Formatting Without Modifying Files Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md Use this command to check code formatting with StyLua without making any changes to the files. This is useful for verifying compliance before committing. ```sh stylua --check . ``` -------------------------------- ### EditorConfig Configuration Source: https://github.com/adriankarlen/bar.wezterm/blob/main/AGENTS.md This INI configuration file specifies editor settings such as final newline and indentation style, ensuring consistency across different editors. ```ini [*] insert_final_newline = true indent_style = space indent_size = 2 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.