Skip to content

feat(actions): support open link from powershell wsl (#284)#292

Merged
linrongbin16 merged 3 commits intolinrongbin16:masterfrom
jtrungle:support-powershell
Jan 19, 2026
Merged

feat(actions): support open link from powershell wsl (#284)#292
linrongbin16 merged 3 commits intolinrongbin16:masterfrom
jtrungle:support-powershell

Conversation

@jtrungle
Copy link
Contributor

Adding condition to open via powershell - this is set as a later priority than wslview as a fallback should a user is using wslview for whatever reason. powershell.exe should exist on all windows platforms via wsl and is the standard interop interface

Test Platforms

  • windows
  • macOS
  • linux

Test Hosts

Test Functions

  • Use GitLink(!) to copy git link (or open in browser).
  • Use GitLink(!) blame to copy the /blame link (or open in browser).
  • Use GitLink(!) default_branch to open the /main//master link in browser (or open in browser).
  • Use GitLink(!) current_branch to open the current branch link in browser (or open in browser).
  • Copy git link in a symlink directory of git repo.
  • Copy git link in an un-pushed git branch, and receive an expected error.
  • Copy git link in a pushed git branch but edited file, and receive a warning says the git link could be wrong.
  • Copy git link with 'file' and 'rev' parameters.

@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 17, 2026

In my local Windows machine, I test this command, but found some error. I tested with this URL: "https://github.com/linrongbin16/gitlinker.nvim/blob/d991b0fc12551227ab345e428696092ff2d117fc/codecov.yml?plain=1#L1"

With "cmd.exe /C start", it works correctly without warnings/errors:

image

With "powershell.exe -Command Start-Process", it works correctly but has some warnings/errors:

Ignore the "mise" warnings, it is my personal dev tools.

image

With "pwsh.exe -Command Start-Process", it works correctly but also has some warnings/errors:

image

@jtrungle
Copy link
Contributor Author

Hm thats interesting - I can't reproduce that error on my local native windows. I'm on version 5.1.26100.6899

image

I'm not too sure what's causing that issue.

But now that i think about it further theres probably a cleaner way to resolve all

 local function system(url)
   if vim.fn.has("mac") > 0 then
     vim.fn.jobstart({ "open", url })
-  elseif vim.fn.has("win32") > 0 or vim.fn.has("win64") > 0 then
-    if vim.fn.executable("powershell.exe") > 0 then
-      vim.fn.jobstart({ "powershell.exe", "-Command", "Start-Process", url })
-    else
-      vim.fn.jobstart({ "cmd", "/C", "start", url })
-    end
+  elseif vim.fn.has("win32") > 0 or vim.fn.has("win64") > 0 or vim.fn.has('wsl') > 0 then
+    vim.fn.jobstart({ "cmd.exe", "/C", "start", url })
   elseif vim.fn.executable("wslview") > 0 then
     vim.fn.jobstart({ "wslview", url })
   else

@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 17, 2026

+  elseif vim.fn.has("win32") > 0 or vim.fn.has("win64") > 0 or vim.fn.has('wsl') > 0 then

For this line, I don't understand, vim.fn.has('wsl') means current nvim is running inside Windows WSL2 (a linux virtual machine), it will not have a cmd.exe.

@jtrungle
Copy link
Contributor Author

Yeah I can see the confusion, but WSL has interoperability support for windows commands, so it will have cmd.exe in its path https://learn.microsoft.com/en-us/windows/wsl/filesystems

@linrongbin16
Copy link
Owner

linrongbin16 commented Jan 17, 2026

Yeah I can see the confusion, but WSL has interoperability support for windows commands, so it will have cmd.exe in its path https://learn.microsoft.com/en-us/windows/wsl/filesystems

I see, I tested "cmd.exe" in Ubuntu wsl and it works.


In ubuntu WSL, bash can find "cmd.exe" (but not "cmd"), can find "powershell.exe"/"pwsh.exe" (but not "powershell"/"pwsh")

image

@jtrungle
Copy link
Contributor Author

Yeah I can see the confusion, but WSL has interoperability support for windows commands, so it will have cmd.exe in its path https://learn.microsoft.com/en-us/windows/wsl/filesystems

I see, I tested "cmd.exe" in Ubuntu wsl and it works.

In ubuntu WSL, bash can find "cmd.exe" (but not "cmd"), can find "powershell.exe"/"pwsh.exe" (but not "powershell"/"pwsh")

image

Yep thats included in the previous commit

@linrongbin16
Copy link
Owner

Thank you!

@linrongbin16 linrongbin16 merged commit e0b0c99 into linrongbin16:master Jan 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants