From fa03487d715fc04e9894a7ce64d6e454cf55ec62 Mon Sep 17 00:00:00 2001 From: sarahyack Date: Thu, 22 May 2025 08:54:56 -0600 Subject: [PATCH] fix(windows): pick appropriate powershell command --- lua/livepreview/utils.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/livepreview/utils.lua b/lua/livepreview/utils.lua index 873bcfa0..ce64589c 100644 --- a/lua/livepreview/utils.lua +++ b/lua/livepreview/utils.lua @@ -125,6 +125,10 @@ function M.isWindows() return vim.uv.os_uname().version:match("Windows") end +---@type pwsh|powershell +local powershell_cmd = vim.fn.executable("pwsh") == 1 and "pwsh" + or "powershell" + --- Execute a shell commands ---@async ---@param cmd string: terminal command to execute. Term_cmd will use sh or pwsh depending on the OS @@ -136,7 +140,7 @@ end function M.term_cmd(cmd, callback) local shell = "sh" if M.isWindows() then - shell = "pwsh" + shell = powershell_cmd end local on_exit = function(result) @@ -158,7 +162,7 @@ end function M.await_term_cmd(cmd) local shell = "sh" if M.isWindows() then - shell = "pwsh" + shell = powershell_cmd end local results = vim.system({ shell, "-c", cmd }, { text = true }):wait() return results