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.
3
  • Where "too much typing"?? Define your --action in your alias.
    – Maximus
    May 31 '13 at 14:25
  • I do not just open pdf files, also open . or sth other files, so I can't change the alias.
    – mike
    May 31 '13 at 14:31
  • @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
    Jun 1 '13 at 6:48
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
}
1
  • 2
    BTW, 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
    May 13 '15 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.