Skip to content

Instantly share code, notes, and snippets.

@himanoa
Created June 8, 2021 17:19
Show Gist options
  • Save himanoa/92f4bbb0cbb247adecb5dc3e4fc0171c to your computer and use it in GitHub Desktop.
Save himanoa/92f4bbb0cbb247adecb5dc3e4fc0171c to your computer and use it in GitHub Desktop.
#!/usr/bin/env zx
const path = process.argv[3]
const matches = path.match(/^([A-Z]):(.+\n?)/)
if(matches) {
const [_, driveLetter, path] = matches
const unixPath = path.replace(/\\/g, "/").replace(/([ \(\)])/g, '\\$1');
const lowerDriveLetter = driveLetter.toLowerCase();
console.log(`/mnt/${lowerDriveLetter}${unixPath}`);
} else {
console.log(path)
}
@himanoa
Copy link
Author

himanoa commented Jun 8, 2021

How to use

zx https://gist.githubusercontent.com/himanoa/92f4bbb0cbb247adecb5dc3e4fc0171c/raw/6e78859da481ac8c7a17957f9f9e5b493bc7702c/change-path-from-win-to-wsl2 "WindowsFilePath"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment