Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions lua/Navigator/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ local U = {}
---@param cmd string
---@return unknown
function U.execute(cmd)
local handle = assert(io.popen(cmd), string.format('[Navigator] Unable to execute cmd - %q', cmd))
local handle = assert(io.popen(cmd .. '>/dev/null 2>&1'), string.format('[Navigator] Unable to execute cmd - %q', cmd))
local result = handle:read()
handle:close()
return result
end

local suffix_cache = nil
---Returns executable suffix based on platform
---@return string
function U.suffix()
local uname = vim.loop.os_uname()
if string.find(uname.release, 'WSL.*$') or string.find(uname.sysname, '^Win') then
return '.exe'
end
return ''
U.suffix = function()
if not suffix_cache then
suffix_cache = '' -- default to empty, overwrite if it's windows
local obj = vim.system({ 'wezterm.exe', '--help' }):wait() -- if exe exists
if obj.code == 0 then
suffix_cache = '.exe'
end
end
return suffix_cache
end

return U