local function resolve_script_path()
for _, plugin in ipairs(wezterm.plugin.list()) do
if plugin.url == "https://github.com/MLFlexer/smart_workspace_switcher.wezterm" then
return plugin.plugin_dir .. "/script/workspace_switcher.sh"
end
end
end
wezterm.on("smart_workspace_switcher", function(window, pane)
local path = resolve_script_path()
if not path then
wezterm.log_error("workspace_switcher.sh not found")
return
end
rationale: logic that runs unconditionally at the file scope is run every time wezterm needs to create a lua context, which can be several times when a config is reloaded, and additional times in various timer or background processing scenarios.
It's best to defer the real work until you actually need to trigger it, hence this suggestion!
rather than:
https://github.com/MLFlexer/smart_workspace_switcher.wezterm/blob/31545dbf40f961bdc0854c3a78be22f60f37e977/plugin/init.lua#L4-L14
I'd suggest
rationale: logic that runs unconditionally at the file scope is run every time wezterm needs to create a lua context, which can be several times when a config is reloaded, and additional times in various timer or background processing scenarios.
It's best to defer the real work until you actually need to trigger it, hence this suggestion!