From 77a0d42943d8265271e6e6beaed72da54eeb17e7 Mon Sep 17 00:00:00 2001 From: luca-sartore-prorob <59091319+lucaSartore@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:06:41 +0100 Subject: [PATCH] fix: explicitly use cmd on windows to avoid problem using powershell (#145) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a user is on windows, and is using powershell as the default nvim shell the command at [line 69 of utils.lua](https://github.com/lucaSartore/lazygit.nvim/blob/main/lua/lazygit/utils.lua#L67C2-L67C130) won’t work due to the `&&` operator. > local cmd = string.format('cd "%s" && git rev-parse --show-toplevel', fn.fnamemodify(fn.resolve(fn.expand('%:p')), ':h'), root) I fixed this by forcing the use of cmd. --- lua/lazygit/utils.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazygit/utils.lua b/lua/lazygit/utils.lua index 08b3415..d86628b 100644 --- a/lua/lazygit/utils.lua +++ b/lua/lazygit/utils.lua @@ -48,10 +48,13 @@ end --- Get project_root_dir for git repository local function project_root_dir() - -- always use bash on Unix based systems. local oldshell = vim.o.shell if vim.fn.has('win32') == 0 then + -- always use bash on Unix based systems. vim.o.shell = 'bash' + else + -- always use cmd on Windows systems. + vim.o.shell = 'cmd' end local cwd = vim.loop.cwd()