Skip to content

srackham/tabsets.wezterm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tabsets.wezterm

A WezTerm plugin to save and load named tab sets.

Features

Commands to load, save, rename and delete named sets of tabs.

Usage

  • Use key bindings or palette commands to save, load, rename and delete tabsets †.
  • Loaded tabs are appended to the current window.
  • If the window is empty (only contains a single empty tab), then the empty tab is deleted.
  • If the window is empty, then window dimensions and custom colors are optionally restored.
  • Tabsets are stored as JSON files with a .tabset.json file name extension in the ~/.config/wezterm/tabsets.wezterm/ directory †.

† See Installation and Configuration.

Prerequisites

  • POSIX commands: rm, test, which, mkdir, rmdir, mv.
  • Optional notify-send command for desktop notifications workaround.

Limitations

  • Tabsets span a single WezTerm window.
  • Panes are recreated with splits; manually resized panes are restored to their default split size.

Installation and Configuration

Add the following code to your wezterm.lua configuration file:


local tabsets = wezterm.plugin.require("https://github.com/srackham/tabsets.wezterm")
tabsets.setup({
  -- Optional configuration options showing the default values

  -- Restore custom colors when loading empty window
  restore_colors = false,

  -- Restore window dimensions when loading empty window
  restore_dimensions = false,

  -- Path to the directory containing tabset JSON files
  tabsets_dir = wezterm.config_dir .. "/tabsets.wezterm"

  -- Fuzzy-match tabset name selection
  fuzzy_selector = false,
})

Optional tabsets key bindings to config configuration builder:

wezterm.on("save_tabset", function(window) tabsets.save_tabset(window) end)
wezterm.on("load_tabset", function(window) tabsets.load_tabset(window) end)
wezterm.on("delete_tabset", function(window) tabsets.delete_tabset(window) end)
wezterm.on("rename_tabset", function(window) tabsets.rename_tabset(window) end)

for _, v in ipairs({
  { key = "S", mods = "LEADER|SHIFT", action = wezterm.action { EmitEvent = "save_tabset" } },
  { key = "L", mods = "LEADER|SHIFT", action = wezterm.action { EmitEvent = "load_tabset" } },
  { key = "D", mods = "LEADER|SHIFT", action = wezterm.action { EmitEvent = "delete_tabset" } },
  { key = "R", mods = "LEADER|SHIFT", action = wezterm.action { EmitEvent = "rename_tabset" } },
})
do table.insert(config.keys, v) end

Optional tabsets Palette bindings:

-- Palette commands are accumulated in this table and then installed with the "augment-command-palette" event
local palette_commands = {}

-- Add tabsets Palette bindings
for _, v in ipairs({
  {
    brief = "Tabset: Save",
    icon = "md_content_save",
    action = wezterm.action_callback(tabsets.save_tabset),
  },
  {
    brief = "Tabset: Load",
    icon = "cod_terminal_tmux",
    action = wezterm.action_callback(tabsets.load_tabset),
  },
  {
    brief = "Tabset: Delete",
    icon = "md_delete",
    action = wezterm.action_callback(tabsets.delete_tabset),
  },
  {
    brief = "Tabset: Rename",
    icon = "md_rename_box",
    action = wezterm.action_callback(tabsets.rename_tabset),
  },
})
do table.insert(palette_commands, v) end

-- Install Palette commands
wezterm.on("augment-command-palette", function() return palette_commands end)

Credits

About

A WezTerm plugin to save and load named tab sets.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages