From 4cfeb18632a45c5c79f18c163e32bc138112f1bb Mon Sep 17 00:00:00 2001 From: Baptiste Ottino Date: Fri, 23 Aug 2024 20:48:28 +0200 Subject: [PATCH 1/2] Fix opening files with explorer in WSL The OS command to open file in explorer in WSL doesn't currently work as expected; it always opens the file explorer at the default opening location. This is because the {{filename}} variable returns the path in WSL format, and not in the format expected by Windows. We use wslpath, a utility shipped with WSL, to make the path conversion. --- pkg/config/config_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index 8aaea4576db..a4c61df4f5d 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -21,7 +21,7 @@ func isContainer() bool { func GetPlatformDefaultConfig() OSConfig { if isWSL() && !isContainer() { return OSConfig{ - Open: `powershell.exe start explorer.exe {{filename}} >/dev/null`, + Open: `powershell.exe start explorer.exe "$(wslpath -w {{filename}})" >/dev/null`, OpenLink: `powershell.exe start {{link}} >/dev/null`, } } From 1543b83d10406066801f34a5192335e6a0dc89c4 Mon Sep 17 00:00:00 2001 From: Baptiste Ottino Date: Fri, 23 Aug 2024 20:52:27 +0200 Subject: [PATCH 2/2] Fix opening links containing ampersands (&) in WSL Opening links containing ampersands inside lazygit (a pull-request creation page in BitBucket Server, for instance) returns the following Powershell error: > The ampersand (&) character is not allowed. The & operator is reserved > for future use; wrap an ampersand in double quotation marks ("&") to > pass it as part of a string. We fix it by enclosing the URL in single quotes. --- pkg/config/config_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index a4c61df4f5d..aa3793901fc 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -22,7 +22,7 @@ func GetPlatformDefaultConfig() OSConfig { if isWSL() && !isContainer() { return OSConfig{ Open: `powershell.exe start explorer.exe "$(wslpath -w {{filename}})" >/dev/null`, - OpenLink: `powershell.exe start {{link}} >/dev/null`, + OpenLink: `powershell.exe start '{{link}}' >/dev/null`, } }