-
Notifications
You must be signed in to change notification settings - Fork 0
/
workspace_sessionizer.lua
59 lines (51 loc) · 1.53 KB
/
workspace_sessionizer.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local wezterm = require 'wezterm'
local M = {}
local function normalize_path(path)
local is_win = string.find(wezterm.target_triple, 'windows') ~= nil
return is_win and path:gsub('\\', '/') or path
end
local home = normalize_path(wezterm.home_dir)
local folders_to_search = {
home .. '/src',
home .. '/src/work',
home .. '/src/work/ekl',
home .. '/src/oss',
}
-------------------------------------------------------
M.start = function(window, pane)
local projects = {}
for _, folder in ipairs(folders_to_search) do
wezterm.log_info(folder)
for _, project in pairs(wezterm.glob(folder .. '/*')) do
project = normalize_path(project)
table.insert(projects, { label = project, id = project })
end
end
window:perform_action(
wezterm.action.InputSelector {
action = wezterm.action_callback(function(win, _, id, label)
if not id and not label then
wezterm.log_info 'Select Project cancelled'
else
wezterm.log_info('Selected project: ' .. label)
win:perform_action(
wezterm.action.SwitchToWorkspace {
name = id,
spawn = {
cwd = label,
-- args = { 'nu', '-e', 'br' }, -- opens broot directly
args = { 'nu' }, -- just open shell
},
},
pane
)
end
end),
fuzzy = true,
title = 'Select project',
choices = projects,
},
pane
)
end
return M