Skip to content

Instantly share code, notes, and snippets.

@S1M0N38
Created May 5, 2025 13:36
Show Gist options
  • Save S1M0N38/b7ea72a7145e4dfe85a727bc53a59d81 to your computer and use it in GitHub Desktop.
Save S1M0N38/b7ea72a7145e4dfe85a727bc53a59d81 to your computer and use it in GitHub Desktop.
Fuzzy projects / Workspaces
local wezterm = require("wezterm")
local config = wezterm.config_builder()
local action = wezterm.action
--------------------------------------------------------------------------------
-- Workspaces
--------------------------------------------------------------------------------
local function project_dirs()
local projects = { wezterm.home_dir }
for _, dir in ipairs(wezterm.glob(os.getenv("HOME") .. "/Developer/*")) do
table.insert(projects, dir)
end
return projects
end
local function choose_project()
local choices = {}
for _, value in ipairs(project_dirs()) do
table.insert(choices, { label = value })
end
return wezterm.action.InputSelector({
title = "Projects",
choices = choices,
fuzzy = true,
action = wezterm.action_callback(function(child_window, child_pane, _, label)
if not label then
return
end
child_window:perform_action(
wezterm.action.SwitchToWorkspace({
name = label:match("([^/]+)$"),
spawn = { cwd = label },
}),
child_pane
)
end),
})
end
--------------------------------------------------------------------------------
-- Keys
--------------------------------------------------------------------------------
config.keys = {
-- Debugger
{ key = "d", mods = "SHIFT | CTRL", action = wezterm.action.ShowDebugOverlay },
-- Launcher Menu
{
key = "l",
mods = "SHIFT | CTRL",
action = action.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES|LAUNCH_MENU_ITEMS" }),
},
-- Create Workspace
{
key = "o",
mods = "SHIFT | CTRL",
action = choose_project(),
},
-- Shift + Enter (Neovim)
{
key = "Enter",
mods = "SHIFT",
action = wezterm.action.SendString("\x1b[13;2u"),
},
-- Ctrl + Enter (Neovim)
{
key = "Enter",
mods = "CTRL",
action = wezterm.action.SendString("\x1b[13;5u"),
},
-- Ctrl + Shift + Enter (Neovim)
{
key = "Enter",
mods = "CTRL|SHIFT",
action = wezterm.action.SendString("\x1b[13;6u"),
},
}
--------------------------------------------------------------------------------
return config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment