WezTerm plugin for per-project workspace switching.
Scans projects in specified directories and allows you to create or switch to a workspace for each project.
- Automatic Project Detection: Automatically detects projects in specified base directories
- Workspace Management: Create and switch to independent workspaces for each project
- Path Shortening: Optionally shorten long project paths for better display
Clone this repository into your WezTerm plugins directory:
git clone https://github.com/sei40kr/wez-per-project-workspace.git $XDG_CONFIG_HOME/wezterm/plugins/wez-per-project-workspaceAdd the following configuration to your wezterm.lua:
local wezterm = require("wezterm")
local config = wezterm.config_builder()
-- Add project workspace selection functionality
config.keys = {
{
key = "g",
mods = "LEADER",
action = require("plugins.wez-per-project-workspace.plugin").action.ProjectWorkspaceSelect({
base_dirs = {
{
path = wezterm.home_dir .. "/ghq",
min_depth = 3,
max_depth = 3,
},
},
rooters = { ".git" },
shorten_paths = true,
}),
}
}
return config| Option | Default | Description |
|---|---|---|
base_dirs |
{} |
List of base directories to search for projects |
rooters |
{ ".git" } |
Files/directories that identify project roots |
shorten_paths |
true |
Whether to shorten project paths for display |
Each base directory can have the following options:
| Option | Default | Description |
|---|---|---|
path |
Required | Path to the base directory |
min_depth |
1 |
Minimum depth of project root (0 includes the base directory itself) |
max_depth |
1 |
Maximum depth of project root (0 includes the base directory itself) |
action = require("plugins.wez-per-project-workspace.plugin").action.ProjectWorkspaceSelect({
base_dirs = {
{
path = wezterm.home_dir .. "/ghq",
min_depth = 2,
max_depth = 4,
},
{
path = wezterm.home_dir .. "/projects",
min_depth = 1,
max_depth = 2,
},
{
path = wezterm.home_dir .. "/work",
min_depth = 0, -- Treat the work directory itself as a project
max_depth = 0,
}
},
rooters = { ".git", ".projectroot" }, -- Multiple rooters
shorten_paths = true,
})wezterm.on("update-status", function(window, _)
window:set_left_status(
wezterm.format({
{ Attribute = { Intensity = "Bold" } },
{ Text = window:mux_window():get_workspace():gsub("^.*/", "") },
"ResetAttributes",
})
)
end)- Project Detection: Uses
findcommand to detect projects in specified base directories - Root Identification: Identifies project roots based on "rooters" like
.gitdirectories - Workspace Management: Creates and switches to independent workspaces for each project
- Fuzzy Search: Uses WezTerm's InputSelector for fuzzy searching and selection
config.keys = {
{
key = "p", -- Change to LEADER + p
mods = "LEADER",
action = require("plugins.wez-per-project-workspace.plugin").action.ProjectWorkspaceSelect({
-- Configuration options
}),
}
}rooters = { ".git", ".project", "package.json", "Cargo.toml" }