Created
May 5, 2025 13:36
-
-
Save S1M0N38/b7ea72a7145e4dfe85a727bc53a59d81 to your computer and use it in GitHub Desktop.
Fuzzy projects / Workspaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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