2

As a (former) Ubuntu user, I was used to executing commands like

nautilus path/to/folder

or

pcmanfm path/to/folder

depending on the file-explorer app installed on my system. This led to the result that the file-explorer was opened up in the directory of interest, which I called here for exemplary reasons path/to/folder.

Up until now, I could not figure out how to do the same on Windows 10 using the git bash (MINGW64) - shell.

Andreas L.
  • 3,239
  • 5
  • 26
  • 65

2 Answers2

1

Thanks to the comment of @ssbssa, I found 3 versions that worked for me using /c/Users/username/Downloads/Test_files as test-path:

$ explorer `cygpath -w "C:\Users\username\Downloads\Test_files"`

$ explorer `cygpath -w "/c/Users/username/Downloads/Test_files"`

$ explorer `cygpath -w /c/Users/username/Downloads/Test_files`

It is important to note that by employing quotes ".." the command will be accepted no matter which directory-separation type is implemented ("/" or "\" depending on your OS). When leaving the quotes out, it'll work only with the linux-style "/".

What's more, it is essential to wrap the cygpath -w path/to/folder - command into a pair of back-ticks "", otherwise the entire command will open a default folder in your windows explorer instead of the target folder. This is by the way (one of) the default fall-back behavior in case something goes wrong, as far as I've experienced it.

To be honest, I would love to know a way of doing the same thing just with a command like

$ explorer /c/Users/username/Downloads/Test_files

since otherwise it seems a bit unpractical to type this cygpath -w .. - wrapper around the command.

If you know a simplification of that, or an easier approach altogether, kindly let me know.


EDIT - Solution found thanks to @ssbssa's comment:

One can set a new bash-function in the bash shell via

explore() { explorer `cygpath -w $1`; }

Then, open the Windows Explorer in the folder of interest via

explore path/to/folder
Andreas L.
  • 3,239
  • 5
  • 26
  • 65
1

In case you want the current directory to be opened, you can use

explorer "$(cygpath -w $(realpath .))"
luckydonald
  • 5,976
  • 4
  • 38
  • 58