I am updating my PowerShell aliases to include utilities from the Windows Subsystem for Linux. For example, I want to launch vim from PowerShell.
Set-Alias -name 'vim' -Value 'Start-Vim'
function Start-Vim {
wsl vim $args
}
This Alias works great if I pass in a simple filename (e.g., vim note.txt
), but it fails if I pass in an absolute file path, a relative path anchored with .\
or a relative path with no anchor.
I tried using Resolve-Path to at least get to a single place (a fully resolved path), but that still doesn't work. It launches
vim, but with that path as a new file ("C:\temp\APIM Swap.ps1" [New File]
in status line).
I started down the path of replacing strings (replace \
with /
), but that only solves relative path with no anchor, and string manipulation doesn't feel like the right solution. Plus, drive letters map to mnts in linux, so I need to deal with that.
Is there a way to convert a file path in Windows to its file path in Windows Subsystem for Linux? Or is there another way to integrate WSL utilities?