Is there a way to configure cygstart.exe?

2

As I understand, cygstart associates its argument with the windows standard program set for that case.

But I want to behave my cygwin different than its host in certain cases.

E.g.

alias open='cygstart'
open some.pdf

should open the pdf with SumatraPDF instead of AcrobatReader, since it's more usefull to me when I'm working on cygwin. There is a --action option for open to specify a non default behavior, but that's too much typing.

So is there a way to configure open? Maybe by means of a config file or exporting a variable?

EDIT

The --action/-a doesn't seem to work.

$ open --action=sumatraPDF some.pdf 
Unable to start 'some.pdf': There is no application associated with the given file name extension.

mike

Posted 2013-05-31T09:51:49.193

Reputation: 399

Where "too much typing"?? Define your --action in your alias. – Maximus – 2013-05-31T14:25:02.517

I do not just open pdf files, also open . or sth other files, so I can't change the alias. – mike – 2013-05-31T14:31:17.633

@mike: Cygstart is for invoking a registered Windows handler for non-executable files. If you want to use an alternate program, have you simply tried <path to program.exe> <path to file to be opened>? – Karan – 2013-06-01T06:48:59.163

Answers

2

It is simple enough to create your own open shell function that checks the file extension and does something special for .pdf and uses cygstart for everything else. For instance

function open
{
    case "$1" in
    *.pdf) sumatraPDF "$1";;
    *) cygstart "$1";;
    esac
}

Jim Balter

Posted 2013-05-31T09:51:49.193

Reputation: 139

2BTW, this a repost of an answer -- with a blatantly obvious example added -- that was outrageously, unreasonably, and irresponsibly deleted by a moderator. That was the worst moderation call I have ever seen on SO ... it was illiterate, as it misquoted and misrepresented what I wrote. A reasonable response would have been to ask me to enhance my answer by adding an example. How such a person could become a moderator at SO is beyond me. They certainly shouldn't be. – Jim Balter – 2015-05-13T05:24:49.710