/

WSLからopenコマンドでWSLのパスをエクスプローラーで開く

WSLのCLIからopenコマンドを叩いてWSLのパスを指定して、そのパスをWindows側のエクスプローラーで開く方法です。

# .bashrcに下記を追記します
$ vim ~/.bashrc

function open() {
  local targetpath=$1
  if [ -z "$targetpath" ]; then
      targetpath=$PWD
  fi

  local winpath
  winpath=$(wslpath -w "$targetpath")
  powershell.exe -Command "Start-Process explorer.exe $winpath"
}
alias open=open

$ source ~/.bashrc

以上。