Skip to content

Instantly share code, notes, and snippets.

@lski
Created April 6, 2019 13:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lski/2dad407989860fa32e93632bf50309fd to your computer and use it in GitHub Desktop.
Save lski/2dad407989860fa32e93632bf50309fd to your computer and use it in GitHub Desktop.
wslpath wrapper for using directly in powershell
<#
.SYNOPSIS
Converts windows path into a linux path and vice versa.
.DESCRIPTION
Converts windows path into a linux path and vice versa. Use WSL under the hood, so needs to be installed.
See docs wslpath docs for more information.
.PARAMETER path
The path to convert
.PARAMETER conversion
The direction of conversion windows->linux by default ('-u'). See docs wslpath docs for other options
.EXAMPLE
wslpath $Profile
wslpath $Profile '-w'
#>
function wslpath(
[Parameter(Mandatory)]
[string]
$path,
[ValidateSet('-u', '-w', '-m')]
$conversion = '-u'
) {
wsl 'wslpath' $conversion $path.Replace('\', '\\');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment