Home How To How to Launch a Bash Shell From File Explorer in Windows 10

How to Launch a Bash Shell From File Explorer in Windows 10

by Unallocated Author

Launch Bash on Windows 10 and it will automatically open to your UNIX account’s home folder. Rather than using the cd command to change to another folder, you can launch Bash directly from a folder in File Explorer.

The Easy Option: Use the Address Bar

When you want to launch bash at a specific folder, just navigate to that folder in File Explorer normally. Click the address bar while in that folder, type “bash”, and press Enter.

opening-bash-in-windows

You’ll get a Bash prompt window focused in the folder you selected.

For example, if you type “bash” directly in the root of the C: drive, Bash will open with the directory /mnt/c selected

opening-bash-in-windows-2

The Right-Click Option: Add a Context Menu Option by Editing the Registry

Perhaps you’d rather have a context menu option like the “Open command window here” option that appears when you hold Shift and right-click inside a folder in File Explorer.

To get this kind of Bash shortcut, you’ll need to edit the registry and add this feature yourself. If you’d rather not do this by hand, we have a quick .reg file you can run below instead.

Standard warning: The Registry Editor is a powerful tool and misusing it can render your system unstable or even inoperable. This is a pretty simple hack and as long as you stick to the instructions, you shouldn’t have any problems. That said, if you’ve never worked with it before, consider reading about how to use the Registry Editor before you get started. And definitely back up the Registry (and your computer!) before making changes.

First, open the registry editor by pressing the Windows key, typing “regedit” into the Start menu, and pressing “Enter”.

opening-bash-in-windows-3

Navigate to the following key:

HKEY_CLASSES_ROOT\Directory\Background\shell

Right-click the “shell” key and select New > Key.

opening-bash-in-windows-4

Name the key “bash” or something similar. You can name it anything you want. This name doesn’t appear in Windows anywhere, and is just used to keep track of the entry in the registry.

opening-bash-in-windows-5

Select “bash” (or whatever you named the key) in the left pane.

Double-click “(Default)” in the right pane and enter whatever name you want to appear in File Explorer’s context menu. For example, you could enter “Open a Bash shell here” or just “Bash”.

opening-bash-in-windows-6

If you want the Bash entry to have an icon in File Explorer’s context menu, right-click the “bash” key and select New > String Value.

Name the value “Icon”, double-click it, and enter the following value:

%USERPROFILE%\AppData\Local\lxss\bash.ico

Skip this step and don’t create an “Icon” value at all if you don’t want an icon in the menu.

opening-bash-in-windows-7

Next, right-click the “bash” key and select New > Key.

Name it “command”.

opening-bash-in-windows-8

With the “command” key selected in the left pane, double-click “(Default)” in the right pane and enter the following value:

C:\Windows\System32\bash.exe

opening-bash-in-windows-9

You’re done. You can now right-click a folder in File Explorer and select “Open a Bash shell here” (or whatever you named the option) to quickly open a Bash shell to that specific folder. This option will appear immediately, so you don’t have to sign out or reboot first.

opening-bash-in-windows-10

Source: Howtogeek

You may also like