Skip to content

Commit

Permalink
use run_child_process instead of io.popen to run zoxide
Browse files Browse the repository at this point in the history
  • Loading branch information
MLFlexer committed Oct 25, 2023
1 parent fa39ec8 commit 308ba8c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ local wezterm = require("wezterm")
local act = wezterm.action

local function get_zoxide_workspaces(workspace_formatter)
local handle = io.popen('zoxide query -l | sed -e "s|^' .. wezterm.home_dir .. '/|~/|"')
local output = handle:read("*a")
handle:close()
local _, stdout, _ = wezterm.run_child_process({ "zoxide", "query", "-l" })

local workspace_table = {}
for _, workspace in ipairs(wezterm.mux.get_workspace_names()) do
Expand All @@ -13,10 +11,11 @@ local function get_zoxide_workspaces(workspace_formatter)
label = workspace_formatter(workspace),
})
end
for _, path in ipairs(wezterm.split_by_newlines(output)) do
for _, path in ipairs(wezterm.split_by_newlines(stdout)) do
local updated_path = string.gsub(path, wezterm.home_dir, "~")
table.insert(workspace_table, {
id = path,
label = path,
label = updated_path,
})
end
return workspace_table
Expand Down

0 comments on commit 308ba8c

Please sign in to comment.