The WezTerm Session Manager is a Lua script enhancement for WezTerm that provides functionality to save, load, and restore terminal sessions. This tool helps manage terminal sessions, its goal is to save and restore different sessions or better workspaces and later restore them.
Clone the Repository Clone the Repository into your WezTerm configuration directory:
git clone https://github.com/oubiwann/wezterm-session-manager.git \
~/.config/wezterm/wezterm-session-manager
Configure WezTerm: Edit your 'wezterm.lua' file to include the Session Manager:
local session_manager = require("wezterm-session-manager/session-manager")
Setup Event Bindings: Edit your 'wezterm.lua' to include the event bindings to trigger the functions of the session manager
wezterm.on("save-session", function(window) session_manager.save_state(window) end)
wezterm.on("restore-session", function(window) session_manager.restore_state(window) end)
Set Keybindings: Define Keybindings in your 'wezterm.lua' for saving, restoring and loading sessions:
local wezterm = require 'wezterm';
return {
keys = {
{key = "S", mods = "LEADER", action = wezterm.action{EmitEvent = "save-session"}},
{key = "R", mods = "LEADER", action = wezterm.action{EmitEvent = "restore-session"}},
},
}
I also recommend to set up a keybinding for creating named workspaces as explained here. This helps managing and switching states.
There are currently some limitations and improvements that need to be implemented:
Feedback, bug reports, and contributions to enhance the script are welcome.