WSL 'Bash Here' Context Menu Item
07 May 2017Similarly to how you can hold shift
whilst you right click on a directory within Windows explorer to open a new command prompt at that directory, it is also possible to do the same with the new WSL Bash. This can make it much easier to work with files within explorer from within the WSL as opposed to lengthy cd
commands to the relevant mnt
.
To add the new context menu item for Bash within explorer, you need to create a new key within the registry and a few new values underneath it:
- Open the registry editor by searching for
regedit
or going throughWin+R
. You will need admin privileges to open the editor. - (Optional) Backup your registry via File->Export.
- Navigate to the key
HKEY_CLASSES_ROOT\Directory\Background\shell
. - Create a new key called
WSL
under shell and and another key underneathWSL
calledcommand
. This should reflect the structure in thecmd key
within shell. The newly created structure should beHKEY_CLASSES_ROOT\Directory\Background\shell\WSL\command
. - Change the
Default
value under theWSL
key to the value you want to see in the context menu e.g. ‘Bash Prompt Here’. - (Optional) Create a new String value called
Icon
under theWSL
key with a value of%USERPROFILE%\\AppData\\Local\\lxss\\bash.ico
. This will make the bash icon appear in the context menu as seen in the screenshot above. - Change the
Default
value under thecommand
key tocmd.exe /c pushd "%V" && bash.exe
. - Exit the editor and test by right clicking the white space within any directory in Windows Explorer.
You should something corresponding to the screenshot. Selecting the new menu item will open up a new WSL Bash prompt starting at the current directory.
Here is the contents of a .reg
file you can also use instead of the above. Simply copy the contents into a file with the .reg
extension and then double click on it to merge it into your registry.