LoginSignup
21
12

More than 5 years have passed since last update.

WSLでmacのopenコマンドみたいなこと

Last updated at Posted at 2017-06-05

Windows10標準の仮想Linux環境Windows Subsystem for Linux1(以下WSLと表記) が着実に進化しています。Unix系のコマンドの豊富な資産がほぼそのまま利用可能な上に(いくつか正常に動作しないものもありますが)、Windows側のファイルシステムの読み書きが可能でWindowsコマンドも呼び出せます。

今回小ネタで、macOSのopenコマンドのようにWSLからファイルを引数として指定してWindows上で開くようなエイリアスを定義してみました。

alias open="cmd.exe /c start"

これを .bashrc 等に定義しておけば、

$ open file-path

で指定したファイルをWindows上で開いてくれます。WSL上のパスを指定してもちゃんとWindowsのパスに変換されます。ただし、Windowsから見えないWSL固有のファイルシステム上のファイルは当然開けません。


  1. もともと Bash on Windowsという名前でしたが、変更されています。それにあわせて記事の表現を若干変更しています。 

21
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
12