Bash on Ubuntu on Windowsをエクスプローラー右クリックで任意のディレクトリをカレントにして起動する方法

Bash on Ubuntu on Windows便利ですね。

さらに便利にするためにフォルダ右クリックでそのフォルダをカレントにしてBashを起動できるようにします。

設定方法

このテキスト↓をコピーして、デスクトップなどにinst_bash_on_ubuntu.regというファイル名で保存します。

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash_on_ubuntu]
@="Bash on Ubuntu(&B)"
[HKEY_CLASSES_ROOT\Directory\Background\shell\bash_on_ubuntu\command]
@="cmd.exe /c @pushd \"%V\"&@C:\\Windows\\System32\\bash.exe"
[HKEY_CLASSES_ROOT\Directory\shell\bash_on_ubuntu]
@="Bash on Ubuntu(&B)"
[HKEY_CLASSES_ROOT\Directory\shell\bash_on_ubuntu\command]
@="cmd.exe /c @pushd \"%V\"&@C:\\Windows\\System32\\bash.exe"
[HKEY_CLASSES_ROOT\Drive\Background\shell\bash_on_ubuntu]
@="Bash on Ubuntu(&B)"
[HKEY_CLASSES_ROOT\Drive\Background\shell\bash_on_ubuntu\command]
@="cmd.exe /c @pushd \"%V\"&@C:\\Windows\\System32\\bash.exe"
[HKEY_CLASSES_ROOT\Drive\shell\bash_on_ubuntu]
@="Bash on Ubuntu(&B)"
[HKEY_CLASSES_ROOT\Drive\shell\bash_on_ubuntu\command]
@="cmd.exe /c @pushd \"%V\"&@C:\\Windows\\System32\\bash.exe"

次にinst_bash_on_ubuntu.regを右クリックして[結合]を実行します。

bouow_migi0.png

下の画像のように確認のダイアログが2回出るので、両方とも[はい]をクリックします。

bouow_migi1.png

bouow_migi2.png

これでフォルダやドライブの右クリックに[Bash on Ubuntu(B)]が表示されます。

bouow_migi3.png

これをクリックするとそのフォルダをカレントにBashが起動します。

bouow_migi4.png

アンインストール方法

もし、右クリックメニューのBash on Ubuntuを消したくなったら、このテキスト↓をコピーしてuinst_bash_on_ubuntu.regというファイル名で保存します。

Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Directory\Background\shell\bash_on_ubuntu]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\bash_on_ubuntu\command]
[-HKEY_CLASSES_ROOT\Directory\shell\bash_on_ubuntu]
[-HKEY_CLASSES_ROOT\Directory\shell\bash_on_ubuntu\command]
[-HKEY_CLASSES_ROOT\Drive\Background\shell\bash_on_ubuntu]
[-HKEY_CLASSES_ROOT\Drive\Background\shell\bash_on_ubuntu\command]
[-HKEY_CLASSES_ROOT\Drive\shell\bash_on_ubuntu]
[-HKEY_CLASSES_ROOT\Drive\shell\bash_on_ubuntu\command]

あとは、このファイルを右クリックして[結合]を実行すればOKです。