Open a file from Cygwin

ShellCygwin

Shell Problem Overview


Is there an equivalent to OSX open command in cygwin. open opens a file with the default application for that type.

I want to do something like

$ magic-command file.xls
#excel opens as if file.xls would have been double-clicked

$ magic-command file.txt
#notepad opens as if file.txt would have been double-clicked

You get the idea?

Basically something like a "cygwin-double-click" command.

Shell Solutions


Solution 1 - Shell

You can also use the cygwin utility:

cygstart <your file>

To make things OSX-like add the following to your bashrc

alias open='cygstart'

Don't forget to check out the man page for cygstart.

Solution 2 - Shell

You can use the start command from the CMD like this:

 cmd /c start <your file>

Solution 3 - Shell

explorer <your file>

works too. What is nice is

explorer .

opens a windows explorer window in the current directory. But then

 cygstart . 

does the same thing and does more, but I find 'explorer' slightly easier to remember.

Solution 4 - Shell

I am using Cygwin in Win7. I can run file on windows through ccygwin command line.

 cygstart <your file>

when you run this command your file will open in windows.

Solution 5 - Shell

Under the Windows command-line interpreter (cmd.exe) there is support for the start command. I know of somebody who implemented start in cygwin. You can find the page about it here.

You could also simply call cmd.exe (usually located in /cygdrive/c/windows/system32/cmd.exe) with the following arguments cmd /c "start yourfile.file"

Solution 6 - Shell

If, like me, you are using putty to ssh locally on your windows machine to Cygwin as cmd.exe is a terrible console, you may want to change your sshd service to allow it to access the local desktop (this will only work on certain windows flavors) under the sshd windows service Logon properties.

Solution 7 - Shell

Yes, there is an equivalent to Windows, try with xdg-open <your file>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMo.View Question on Stackoverflow
Solution 1 - ShellerichuiView Answer on Stackoverflow
Solution 2 - Shellf3lixView Answer on Stackoverflow
Solution 3 - ShellpheonView Answer on Stackoverflow
Solution 4 - ShellArmaanView Answer on Stackoverflow
Solution 5 - ShellPierre-Luc SimardView Answer on Stackoverflow
Solution 6 - ShellMariusView Answer on Stackoverflow
Solution 7 - ShellOriol PratView Answer on Stackoverflow