0

Lets say I have a folder open in Windows Explorer like this:

enter image description here

I want that I be able to open a Cygwin terminal directly here by using keyboard shortcut or alteast by doing right click and selecting an option on the pop-up menu that makes it possible to do so. I will also often need to open MinGW, PowerShell or Windows Command Terminal in this way in specific directory.

Right now I open the terminal and then copy-paste and path and use CD command to change the directory. But, I am sure that there must be a quicker way to doing this when we need to do this dozen times everyday for decades.

I am using Windows 10 by the way, and will probably move to Windows 11 soon.

2 Answers 2

1

The folder background context menu is controlled by the HKEY_CLASSES_ROOT\Directory\background\shell registry key. For example, the "Open with Visual Studio" entry is controlled by the AnyCode subkey.

Command Prompt and PowerShell

Windows 10 already has entries for cmd.exe and powershell.exe, but they are hidden by default. You can show the PowerShell one by holding the Shift key while right-clicking the background of the folder window. Command Prompt is hidden when PowerShell is installed using the HideBasedOnVelocityId value.

To always show Command Prompt and PowerShell in the folder background context menu, without needing to hold Shift:

  1. Give yourself permissions to modify the shell key.
    1. Right-click the key in Registry Editor.
    2. Choose Permissions > Advanced.
    3. Change the Owner to Administrators, and check both "Replace owner on subcontainers and objects" and "Replace all child object permissions entries with inheritable permission entries from this object".
    4. Click OK to close the Permissions dialog boxes.
  2. In both the cmd and PowerShell subkeys, delete or rename the Extended, HideBasedOnVelocityId, and ShowBasedOnVelocityId values.

always show cmd

Now when you right-click on the background of a folder, you should see "Open command window here" and "Open PowerShell window here" in the context menu.

New entries

To add new entries to the folder background context menu, you can create new keys in the HKEY_CLASSES_ROOT\Directory\background\shell registry key.

  • The name of the new key can be any unique name you want, it doesn't appear in the UI.
  • The text label of the context menu entry is controlled by the (Default) value in the key.
  • The optional icon of the entry is controlled by the Icon string value in the subkey. It can be the filename of an ICO file, or a PE file (DLL/EXE) with an optional numeric ID separated by a comma. The index can be non-negative for the 0-based index of the icon in the PE file, or negative for the resource ID.
  • The program and arguments to run when you click the entry are controlled by the (Default) value of the command subkey. It uses the %V placeholder variable to represent the current directory.

MinGW Bash example

I have MinGW Bash installed as part of Git for Windows. Here is a .reg file that adds it to my folder background context menu. Your installation directory will probably differ.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash]
@="Open in Bash"
"Icon"="C:\\Programs\\Development\\Git\\mingw64\\share\\git\\git-for-windows.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command]
@="\"C:\\Programs\\Development\\Git\\bin\\bash.exe\""

This opens Bash in the given folder, even thought the command does not use %V, because Windows starts the process with the folder as the new process's working directory by default (unless a NoWorkingDirectory value is present in the key).

bash in folder context menu

I no longer have Cygwin installed, but a menu entry for its Bash can most likely be added in a similar manner.

Windows 11 has an "Open in Terminal" entry always visible in the equivalent menu, although it is more challenging to customize.

0

The latest version of "Git for Windows" does have a "Open Git Bash here" on the File Manager's Right Click Context Menu.

Its Setup Installer is available at its website : https://www.git-scm.com/download/win ( accept its default recommendations, while setup )

Screenshots Below :

Git Bash

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .