I had long been used to doing open . on macOS to get finder windowopen on the current directory in the shell. I wanted something similarunder WSL2, but this is the best I could come up with. It copies thecurrent working directory to the clipboard such that you can press���ctrl-l crtl-v ret��� in the File Explorer and get the same effect.
function wslpwd() { echo //wsl$/Ubuntu$PWD | sed 's:/:\\:g' | pbcopy}
Assumptions
pbcopy is installed WSL distro name is Ubuntu
It prepends the special //wsl$/Ubuntu string to the $PWD, then uses sedto transform the forward slashes to backslashes, then uses pbcopy to putthe result on the system clipboard.
Published on October 30, 2020 10:10