This PR changes three things about how the current code works to make it work on Linux (#44)
Use $Env.HOME over $Env.USERPROFILE
I understand this works on all platforms, this is the only change which Windows users will see from this PR.
Disable the $providerMatches regex check which was preventing the run on Linux
This was the second cross-platform bug in the current code.
The regex I suspect is doing something Windows-specific. It looks like this: '(?i)^((Alias|Env|/|Function|Variable):\\)|(\\{1,2}).*?'. That seems to fail for all paths stored in $global:history on Linux. I've put the code behind a $IsWindows to keep that behaviour there, as I couldn't think of the real use cases where the regex is useful.
Allow $function:tabexpansion2 to work on non-Windows platforms
We were using a -Replace to extend the existing $function:tabexpansion2 which uses Windows-style newlines of \r\n which wasn't matching on Linux and clearing out the whole of the $function:tabexpansion2 variable. I've changed the -Replace matcher to work for \n which is the default newline on Linux and Mac.
Minor things:
VSCode formats Powershell files on save and has disagreements with the current style. I'm happy to resubmit without these formatting changes - but I figured since VSCode is a default text editor these days that you might want to make it easier for others to contribute?
I wasn't sure how to quickly make changes to the module and reimport it to test things. So I made a helper file called reload-module.ps1 which does that. I'm happy to drop this as well if there is a more idiomatic way to do this. This is my first time playing with PowerShell plugins so I found it useful.
This PR changes three things about how the current code works to make it work on Linux (#44)
$Env.HOME
over$Env.USERPROFILE
I understand this works on all platforms, this is the only change which Windows users will see from this PR.
$providerMatches
regex check which was preventing the run on LinuxThis was the second cross-platform bug in the current code.
The regex I suspect is doing something Windows-specific. It looks like this:
'(?i)^((Alias|Env|/|Function|Variable):\\)|(\\{1,2}).*?'
. That seems to fail for all paths stored in$global:history
on Linux. I've put the code behind a$IsWindows
to keep that behaviour there, as I couldn't think of the real use cases where the regex is useful.$function:tabexpansion2
to work on non-Windows platformsWe were using a
-Replace
to extend the existing$function:tabexpansion2
which uses Windows-style newlines of\r\n
which wasn't matching on Linux and clearing out the whole of the$function:tabexpansion2
variable. I've changed the-Replace
matcher to work for\n
which is the default newline on Linux and Mac.Minor things:
reload-module.ps1
which does that. I'm happy to drop this as well if there is a more idiomatic way to do this. This is my first time playing with PowerShell plugins so I found it useful.