### Wezterm Configuration with Keybindings and Plugin Setup Source: https://context7.com/abidibo/wezterm-sessions/llms.txt This comprehensive Lua configuration example demonstrates how to integrate the wezterm-sessions plugin. It includes setting a custom auto-save interval and configuring custom keybindings for workspace management, such as renaming and creating new workspaces. ```lua local wezterm = require("wezterm") local act = wezterm.action local sessions = wezterm.plugin.require("https://github.com/abidibo/wezterm-sessions") local config = {} -- Apply plugin with custom auto-save interval sessions.apply_to_config(config, { auto_save_interval_s = 45, }) -- Add workspace management keybindings table.insert(config.keys, { key = "$", mods = "CTRL|SHIFT", action = act.PromptInputLine({ description = "Enter new workspace name", action = wezterm.action_callback(function(window, pane, line) if line then wezterm.mux.rename_workspace(wezterm.mux.get_active_workspace(), line) end end), }), }) table.insert(config.keys, { key = "w", mods = "CTRL|SHIFT", action = act.PromptInputLine({ description = wezterm.format({ { Attribute = { Intensity = "Bold" } }, { Foreground = { AnsiColor = "Fuchsia" } }, { Text = "Enter name for new workspace" }, }), action = wezterm.action_callback(function(window, pane, line) if line then window:perform_action( act.SwitchToWorkspace({ name = line }), pane ) end end), }), }) return config ``` -------------------------------- ### Wezterm Session State Workspace Data Structure Example Source: https://context7.com/abidibo/wezterm-sessions/llms.txt This Lua code provides an example structure for how workspace data is represented when stored as JSON for session state in Wezterm. It details the hierarchical organization of windows, tabs, and panes, including their properties and layout coordinates. ```lua -- Example workspace state structure (as stored in JSON) local workspace_data = { name = "development", last_modified = 1704067200, -- Unix timestamp windows = { { title = "Main Window", tabs = { { tab_id = "1", title = "editor", is_active = true, panes = { { pane_id = "1", index = 0, is_active = true, is_zoomed = false, left = 0, top = 0, width = 120, height = 40, pixel_width = 1200, pixel_height = 800, cwd = "file:///home/user/project", tty = "nvim src/main.lua", }, { pane_id = "2", index = 1, is_active = false, is_zoomed = false, left = 121, top = 0, width = 60, height = 40, pixel_width = 600, pixel_height = 800, cwd = "file:///home/user/project", tty = "bash", }, }, }, }, }, }, } ``` -------------------------------- ### Create and Rename Workspaces with Keybindings (Lua) Source: https://github.com/abidibo/wezterm-sessions/blob/main/README.md This Lua code configures keybindings for managing named workspaces in WezTerm. It includes functionality to rename the current workspace and to prompt the user for a name to create and switch to a new workspace. The `PromptInputLine` action is used to get user input, and `wezterm.action_callback` handles the logic for applying the changes. ```lua -- Rename current workspace { key = '$', mods = 'CTRL|SHIFT', action = act.PromptInputLine { description = 'Enter new workspace name', action = wezterm.action_callback( function(window, pane, line) if line then wezterm.mux.rename_workspace(wezterm.mux.get_active_workspace(), line) end end ), }, }, -- Prompt for a name to use for a new workspace and switch to it. { key = 'w', mods = 'CTRL|SHIFT', action = act.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( act.SwitchToWorkspace { name = line, }, pane ) end end), }, } ``` -------------------------------- ### Save Session Event Handling Source: https://context7.com/abidibo/wezterm-sessions/llms.txt Triggers the saving of the current workspace state. Includes keybinding configuration and event listeners to monitor the start and completion of the save process. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "s", mods = "ALT", action = act({ EmitEvent = "save_session" }), }, } -- Event listeners for save operations wezterm.on("wezterm-sessions.save.start", function(file_path) wezterm.log_info("Starting save to: " .. file_path) end) wezterm.on("wezterm-sessions.save.end", function(file_path, success) if success then wezterm.log_info("Session saved successfully to: " .. file_path) else wezterm.log_error("Failed to save session to: " .. file_path) end end) ``` -------------------------------- ### Initialize WezTerm Sessions Plugin Source: https://context7.com/abidibo/wezterm-sessions/llms.txt Configures the plugin within the WezTerm configuration file. It accepts an optional user configuration table to customize settings like the auto-save interval. ```lua local wezterm = require("wezterm") local sessions = wezterm.plugin.require("https://github.com/abidibo/wezterm-sessions") local config = {} -- Initialize with default keybindings and custom auto-save interval sessions.apply_to_config(config, { auto_save_interval_s = 60, -- Auto-save every 60 seconds (default: 30) }) return config ``` -------------------------------- ### Default WezTerm Sessions Keybindings Source: https://github.com/abidibo/wezterm-sessions/blob/main/README.md Lists the default keybindings provided by the plugin when apply_to_config is invoked. These bindings facilitate session management actions such as saving, loading, and editing. ```lua ALT + s → Save session ALT + l → Load session ALT + r → Restore session CTRL+SHIFT + d → Delete session CTRL+SHIFT + e → Edit session ALT + a → Toggle auto-save ALT + f → Fork session ``` -------------------------------- ### Load Session via Fuzzy Finder Source: https://context7.com/abidibo/wezterm-sessions/llms.txt Opens a fuzzy finder to select and load a saved session. This allows switching to any previously saved workspace state. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "l", mods = "ALT", action = act({ EmitEvent = "load_session" }), }, } -- Event listeners for load operations wezterm.on("wezterm-sessions.load.start", function(workspace_name) wezterm.log_info("Loading workspace: " .. workspace_name) end) wezterm.on("wezterm-sessions.load.end", function(workspace_name) wezterm.log_info("Workspace loaded: " .. workspace_name) end) ``` -------------------------------- ### Restore Session Event Handling Source: https://context7.com/abidibo/wezterm-sessions/llms.txt Restores the workspace state matching the current name. Provides keybindings and lifecycle event hooks for tracking the restoration process. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "r", mods = "ALT", action = act({ EmitEvent = "restore_session" }), }, } -- Event listeners for restore operations wezterm.on("wezterm-sessions.restore.start", function(workspace_name) wezterm.log_info("Restoring workspace: " .. workspace_name) end) wezterm.on("wezterm-sessions.restore.end", function(workspace_name) wezterm.log_info("Workspace restored: " .. workspace_name) end) ``` -------------------------------- ### Define Custom Keybindings for WezTerm Sessions (Lua) Source: https://github.com/abidibo/wezterm-sessions/blob/main/README.md This Lua code defines custom keybindings for various session management actions in WezTerm. It allows users to map specific key combinations (e.g., ALT+s, CTRL+SHIFT+d) to actions like saving, loading, restoring, or deleting sessions. If custom keybindings are defined, the `apply_to_config` function is not needed. ```lua config.keys = { { key = 's', mods = 'ALT', action = act({ EmitEvent = "save_session" }), }, { key = 'l', mods = 'ALT', action = act({ EmitEvent = "load_session" }), }, { key = 'r', mods = 'ALT', action = act({ EmitEvent = "restore_session" }), }, { key = 'd', mods = 'CTRL|SHIFT', action = act({ EmitEvent = "delete_session" }), }, { key = 'e', mods = 'CTRL|SHIFT', action = act({ EmitEvent = "edit_session" }), }, { key = 'a', mods = 'ALT', action = act({ EmitEvent = "toggle_autosave" }), }, { key = 'f', mods = 'ALT', action = act({ EmitEvent = "fork_session" }), }, } ``` -------------------------------- ### Configure WezTerm Sessions Plugin Source: https://github.com/abidibo/wezterm-sessions/blob/main/README.md Integrates the WezTerm Sessions plugin into the user's WezTerm configuration file. It requires the plugin via URL and allows customization of options like the auto-save interval. ```lua local wezterm = require("wezterm") local act = wezterm.action local sessions = wezterm.plugin.require( "https://github.com/abidibo/wezterm-sessions" ) local config = {} -- Optional: adds default keybindings and plugin configuration sessions.apply_to_config(config, { -- Auto-save interval in seconds (default: 30) auto_save_interval_s = 30, }) return config ``` -------------------------------- ### Emit fork_session Event for Wezterm Source: https://context7.com/abidibo/wezterm-sessions/llms.txt This Lua code snippet configures a keybinding to emit the 'fork_session' event. This event is designed to duplicate the current workspace layout, prompting for a new workspace name and then creating a new session with the same structure. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "f", mods = "ALT", action = act({ EmitEvent = "fork_session" }), }, } ``` -------------------------------- ### Delete Session via Fuzzy Finder Source: https://context7.com/abidibo/wezterm-sessions/llms.txt Provides a mechanism to select and permanently delete a saved session file from the file system using a fuzzy finder. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "d", mods = "CTRL|SHIFT", action = act({ EmitEvent = "delete_session" }), }, } -- Event listeners for delete operations wezterm.on("wezterm-sessions.delete.start", function(file_path) wezterm.log_info("Deleting session file: " .. file_path) end) wezterm.on("wezterm-sessions.delete.end", function(file_path, success) if success then wezterm.log_info("Session deleted: " .. file_path) end end) ``` -------------------------------- ### Emit edit_session Event for Wezterm Source: https://context7.com/abidibo/wezterm-sessions/llms.txt This Lua code snippet defines a keybinding to emit the 'edit_session' event. This event is used to open a fuzzy finder for editing saved session state files. It logs the editing action when the 'wezterm-sessions.edit.start' event is triggered. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "e", mods = "CTRL|SHIFT", action = act({ EmitEvent = "edit_session" }), }, } -- Event listener for edit operations wezterm.on("wezterm-sessions.edit.start", function(file_path, editor) wezterm.log_info("Editing " .. file_path .. " with " .. editor) end) ``` -------------------------------- ### Emit toggle_autosave Event for Wezterm Source: https://context7.com/abidibo/wezterm-sessions/llms.txt This Lua code snippet sets up a keybinding to emit the 'toggle_autosave' event. This event allows users to toggle the automatic periodic saving of the current session state. When enabled, sessions are saved at a configurable interval. ```lua local wezterm = require("wezterm") local act = wezterm.action config.keys = { { key = "a", mods = "ALT", action = act({ EmitEvent = "toggle_autosave" }), }, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.