116

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.

jcardinal
  • 5
  • 4
Mo.
  • 15,033
  • 14
  • 47
  • 57

7 Answers7

201

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.

erichui
  • 2,761
  • 2
  • 20
  • 20
  • 1
    This is really handy! With cygstart you can also run the Edit, Print, etc. actions on files... I'm glad you posted this – f3lix Feb 23 '09 at 13:59
16
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.

pheon
  • 2,867
  • 3
  • 26
  • 33
16

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

 cmd /c start <your file>
f3lix
  • 29,500
  • 10
  • 66
  • 86
  • 1
    I think this answer is better because it works with Cygwin **and** Windows. – Jace Browning Sep 03 '13 at 18:14
  • 5
    There is one interesting difference between this and "cygstart" that I noticed when running under Cygwin's bash shell. Consider the following two commands: 1) `cygstart programThatCrashes.exe` 2) `cmd /c start programThatCrashes.exe` Also, programThatCrashes.exe is a Win32 console program that just crashes. Both launch a new console window to run the program. However, the first one (cygstart) causes a crash dialog to appear and allows just-in-time debugging. The second one (cmd /c start) doesn't seem to let the crash dialog appear. The new console window just closes quietly. – Steve Onorato Jan 24 '14 at 00:42
  • What's more, you can just use `start ` in a Windows cmd console. Specically, you can use `start .` to open current path in File Explorer. – Robert Dec 09 '17 at 07:53
  • 1
    Doesn't work anymore on w10. At least on "Microsoft Windows [Version 10.0.17134.1365]" – saulius2 Apr 14 '20 at 13:19
3

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.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Armaan
  • 2,472
  • 2
  • 20
  • 22
0

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.

Marius
  • 3,372
  • 1
  • 30
  • 36
0

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

Oriol Prat
  • 1,017
  • 1
  • 11
  • 19
0

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"

Pierre-Luc Simard
  • 2,723
  • 19
  • 27