As mentioned, the best way is probably cygstart
. You can add an alias to your .bashrc (or .zshrc or whatever):
alias open='cygstart'
But you can also do some things with explorer.exe
. It's probably not as good as cygstart
but if you run into any problems with that approach (or you need to use this with Git's bash shell rather than Cygwin) it's an option to keep in mind.
Before now I've been using the bash shell that ships with Git for Windows, and I've had
alias open='explorer.exe'
in my .bash_profile. It would open directories in Windows Explorer, and open files in the default application (by Windows' definition of "default").
It does have limitations, though. Since explorer.exe is expecting to be used at a DOS prompt (if at a command line at all), don't expect globbing to work. If, for instance, you want to open your Gemfile, Vagrantfile, Cheffile, and Rakefile all at once, and you type
open *file
You'll just get a Windows Explorer window. I don't know what logic (!?) is at work here. Most likely explorer.exe is just ignoring all the arguments, since it doesn't know what to do with multiple args.
cygstart
is not very intelligent either, as it only opens the first argument when passed multiple arguments, but at least it opens a file, rather than the current directory.
open
is...open
. :) I haven't used Cygwin much; I prefer MobaXterm. – Wildcard Feb 04 '16 at 07:43