Search code examples
linuxwindowscygwindefaultnotepad

How to open a file using specific application in cygwin?


I know that you can open programs in cygwin using cygstart.

I also know that you can open files in a similar fashion. However, I would like to open a file using a specific program. For example, I want to open a text file using sublime and I try:

cygstart -a <nameoffile.txt> sublime_text

But this just opens the default.

I also tried:

cygstart -o <nameoffile.txt> sublime_text 

But this also opens the default application (notepad).

I read the man pages, and those two things seem to be the only commands that might be reasonable for this. How to open a file using specific application in cygwin?


Solution

  • You can usually just use the program executable file itself. If it's in your PATH, then just do:

    <program exe> <name of file to open>&

    The & is necessary to make it a background process, otherwise Cygwin will wait for the program to end before it'll let you use the console again.

    If it's not in your PATH, you can either create a symbolic link to it using ln -s, putting the symbolic link in your PATH, or specify the full path on the command line.