wsinit.wezterm [](https://github.com/michaelbrusegard/awesome-wezterm)

March 2, 2026 ยท View on GitHub

A WezTerm plugin that provides a simple and flexible way to manage and initialize workspace configurations.

wsinit.wezterm requires the WezTerm terminal emulator.

Features

  • Define workspace configurations in separate Lua files.
  • Full access to wezterm.mux API.
  • Quick switching between workspaces via keybinding.

Installation

Install wsinit.wezterm by requiring it in your wezterm.lua configuration file:

local wsinit = wezterm.plugin.require("https://github.com/JuanraCM/wsinit.wezterm")

Type Support

For enhanced development experience (autocompletion, type checking), you can use wezterm-types. This provides type definitions for wsinit.wezterm:

---@type WsInit
local wsinit = wezterm.plugin.require("https://github.com/JuanraCM/wsinit.wezterm")

Configuration

This plugin ships with a default configuration that can be customized through the wsinit.setup({ ... }) function.

local defaults = {
  workspaces_dir = wezterm.config_dir .. "/workspaces", -- Directory for workspace files
  init_workspace_keys = { -- Keybinding to open workspace selector
    key = "w",
    mods = "LEADER",
  },
}

WezTerm configuration

The plugin requires applying keybindings to the WezTerm config. Use wsinit.apply_to_config(config) to automatically set up the workspace selector keybinding. This needs to be called after wsinit.setup().

wsinit.apply_to_config(config)

Creating workspace configurations

Workspace configurations are Lua files stored in your workspaces_dir. Each file should return a table with the following structure:

-- <workspaces_dir>/my_workspace.lua
return {
  -- Optional: Custom label for the workspace selector menu
  -- If not provided, the filename will be used
  label = "My Workspace",
  
  -- Required: Setup function called when initializing the workspace
  -- Receives the same arguments as wezterm.mux.spawn_window
  -- Documentation: https://wezterm.org/config/lua/wezterm.mux/spawn_window.html
  setup = function(tab, pane, window)
    -- Run commands in the first pane
    pane:send_text("echo 'Welcome to My Workspace!'\n")
    
    -- Set tab title
    tab:set_title("My Workspace")
    
    -- Create additional tabs with specific directories
    window:spawn_tab({ cwd = "/path/to/project" })
    
    -- You can create as many tabs and panes as needed
    -- Example: Create a split pane
    local new_tab = window:spawn_tab({ cwd = "/path/to/another/project" })
    new_tab:active_pane():split({ direction = "Right" })
  end,
}

Important Notes

  • Workspace name: The workspace name is derived from the configuration filename.
  • Existing workspaces: If a workspace with the same name already exists, wsinit will switch to it instead of creating a new instance.
  • Reloading required: After creating or editing workspace configuration files, you need to reload your WezTerm configuration.
  • Error checking: If you don't see your workspace in the selection menu, check WezTerm's debug overlay for errors.