Add powershell support to suppress UNC path error

Prefer using powershell.exe over cmd.exe on wsl to supress terminal error:
"CMD.EXE was started with the above path as the current directory"
This commit is contained in:
Christopher Phillips 2022-08-06 13:30:16 -04:00 committed by Fabian Boehm
parent f6e3f4db34
commit 8e3e50f9ee

View File

@ -86,6 +86,12 @@ function help --description 'Show help for the fish shell'
set fish_browser $cmd[1]
end
# Try and see if powershell.exe is an option to avoid UNC path error
# https://ss64.com/nt/cmd.html Launching CMD/batch files from a UNC path
if type -q powershell.exe
set fish_browser powershell.exe
end
if type -q wsl-open
set fish_browser wsl-open
end
@ -224,10 +230,13 @@ function help --description 'Show help for the fish shell'
end
end
# cmd.exe needs more coaxing.
# cmd.exe and powershell needs more coaxing.
if string match -qr 'cmd\.exe$' -- $fish_browser[1]
# The space before the /c is to prevent msys2 from expanding it to a path
$fish_browser " /c" start $page_url
else if string match -qr 'powershell\.exe$' -- $fish_browser[1]
# The space before the /c is to prevent msys2 from expanding it to a path
$fish_browser " /c" start $page_url
# If browser is known to be graphical, put into background
else if contains -- $fish_browser[1] $graphical_browsers
switch $fish_browser[1]