On Mac OS X, there is a command line utility open(1) (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/open.1.html), which opens given files (or directories) as they would be clicked in system user interface, i.e. they are open in the default application for opening that particular file type.
I hacked a very trivial variant of it for Windows some time ago as I found it immensely useful for usage within MSYS2 (or any shell) environment. Perhaps it would be worth of adding it (or some enhanced variant of this) into MSYS2 if other people find it useful too.
The utility source is attached. To build it I normally use CMake, but that's probably unsuitable here as MSYS2 uses autotools. But manual build may be done with this one-liner so adding it into MSYS2 should be trivial.
$ gcc -Wall -municode -DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN -lshell32 open.c -o open.exe
So adding it anywhere into MSYS2 should be likely trivial.
The usage is as simple as:
$ open PATH [PATH...]
If there is any interest in adding it, I am open to add some formal enhancements like man page and/or --help option support etc.
Sounds good. I think adding it to the MSYS2 filesystem package would be appropriate. No need to setup a complex build system, calling gcc from PKGBUILD would be fine IMHO, but if you want to go to town on docs and translation then a build system might become appropriate. Personally I don't think documentation is essential for something as self describing as open. I've not checked but how are you handling mime types? Do we want to have our own wrapper to mime types so that MSYS2-installed stuff gets preference?
But MSYS has already this application! It is called "start" (in an old ticked I asked for cygstart which is in Cygwin, and Alexey clarified...):
with an 'alias' (in shell initialization files) I have solved your issue:
opens foo.pdf with the default PDF reader on Windows. In the same manner
Ciao,
Angelo.
Ohh. I missed "start" completely. Ok, consider the ticket irrelevant then.
BTW, I often use it to install Windows applications,
(exactly as I do on OSX with .dmg applications : 'open LibreOffice_4.3.5[...].dmg')
Also:
On GNU/Linux there is an application (now I don't remember the name...) similar to OSX-open, [cyg]start. So with a similar alias I did the same on GNU/Linux...
Ciao,
Angelo.
@Ray: I do not. I leave the hard work on SHELL32.DLL