Windows 10 version 1607 "Anniversary Update" comes with a new feature called "Bash on Ubuntu". It provides the Linux command line shell "bash" for Windows via a native implementation which runs faster than a virtual machine with Linux installed. It allows running console Linux apps too. If you use it frequently, you might find it useful to have a special context menu command "Open Bash Here" that opens the Bash console in the desired folder with one click. Here is how you can add it.
Advertisеment
In this article I assume that you have Bash on Ubuntu installed and configured in Windows 10. If not, ensure that you are running Windows 10 version 1607 and first install Bash. See these articles for reference:
Once configured, you can apply a Registry tweak as mentioned below.
To add Bash Context Menu in Windows 10, do the following.
- Open Registry Editor.
- Go to the following Registry key:
HKEY_CURRENT_USER\SOFTWARE\Classes\Directory
Tip: see How to jump to the desired registry key with one click
- Create a new subkey here called "shell":
- Under shell, create a new subkey. Give it some recognizable name like "openbashhere":
- Set the value data of the default (unnamed) value under the "openbashhere" subkey to "Open Bash here":
- Under the "openbashhere" subkey, create a new value of type "Expandable String Value" and name it as "Icon":
- Set its value data to:
%USERPROFILE%\AppData\Local\lxss\bash.ico
- Again, under the "openbashhere" key, create a new subkey called "command":
- Set the value data of the default (unnamed) value of the "command" subkey to:
cmd.exe /c cd /d "%V" && bash.exe
- Now, repeat the steps above under the key:
HKEY_CURRENT_USER\SOFTWARE\Classes\Directory\Background
This will add the Open Bash here command to the Directory background context menu:
- Additionally, you can create a similar Registry structure under the key
HKEY_CURRENT_USER\SOFTWARE\Classes\DesktopBackground
To get
HKEY_CURRENT_USER\SOFTWARE\Classes\DesktopBackground\shell\openbashhere\command
Create appropriate values and their data. This will add the Open Bash here command to the context menu of the Desktop context menu.
- Finally, you can create the appropriate keys and values under the following key:
HKEY_CURRENT_USER\SOFTWARE\Classes\Drive\shell\openbashhere
For those who want to avoid Registry editing, a ready-to-use tweak and an undo file are available for download here:
To save your time, use Winaero Tweaker. It has the appropriate option under Context Menu:You can get the app here: Download Winaero Tweaker.
Watch the following video to see this tweak in action:
Tip: you can subscribe to our YouTube channel HERE.
That's it. If you have suggestions or questions - welcome to comments.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment
any way to make this open bash window here “as administrator” instead of standard?
also when applied to win10 pro x64 fcu with the latest winaero tweaker it seems the icon placed in the context menu is blank ><
thanks for all your hard work. invalueable tool :)
Thanks for kind words.
For bash as administrator, replace the command in the Reg file with:
@=”PowerShell -windowstyle hidden -Command \”Start-Process cmd.exe -ArgumentList ‘/k,cd,/d,%V,&&,bash.exe’ -Verb RunAs\””
(I’ve not tested it myself yet but it should work).
It works fine. Can you add it to Winaero Tweaker? Like the same option in powershell and cmd.
Thank you!
It is already there. Type “Bash” in the search box.
Hey, is there any way to run the bash from the context menu in folders with white space in the name?
Like: “C:\Test Folder”?
Thanks for the guide and the tools! :)
A “Show only in Shift + Right click menu” option would be nice
You can add
"Extended"=""
To the Registry tweak.
This suddenly stopped working correctly on my pc. It opens a bash shell, but not in the directory clicked. Instead, it opens in “/”.
The command
cmd.exe /c cd /d “%V” && bash.exe
fails if the selected directory is a WSL Linux path like e.g. /home or /var. For recent WSL versions, a better command is therefor
wsl.exe –cd “%V”
since wsl.exe can handle both Windows and Linux pathes (if “%V” starts with a “/”, it’s automatically handled as Linux path).