简体   繁体   English

从Cygwin打开一个文件

[英]Open a file from Cygwin

Is there an equivalent to OSX open command in cygwin. 在cygwin中是否有与OSX open命令相同的功能。 open opens a file with the default application for that type. open打开一个包含该类型的默认应用程序的文件。

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. 基本上类似于“cygwin-double-click”命令。

You can also use the cygwin utility: 您还可以使用cygwin实用程序:

cygstart <your file>

To make things OSX-like add the following to your bashrc 为了使OSX类似,将以下内容添加到bashrc中

alias open='cygstart'

Don't forget to check out the man page for cygstart. 不要忘记查看cygstart的手册页。

您可以使用CMD中的start命令,如下所示:

 cmd /c start <your file>
explorer <your file>

works too. 也有效。 What is nice is 好的是

explorer .

opens a windows explorer window in the current directory. 在当前目录中打开一个Windows资源管理器窗口。 But then 但是之后

 cygstart . 

does the same thing and does more, but I find 'explorer' slightly easier to remember. 做同样的事情并做得更多,但我发现'探险家'稍微容易记住。

I am using Cygwin in Win7. 我在Win7中使用Cygwin。 I can run file on windows through ccygwin command line. 我可以通过ccygwin命令行在Windows上运行文件。

 cygstart <your file>

when you run this command your file will open in windows. 当您运行此命令时,您的文件将在Windows中打开。

如果像我一样,你使用putty在Windows机器上本地ssh到cygwin,因为cmd.exe是一个糟糕的控制台,你可能想要更改你的sshd服务以允许它访问本地桌面(这只适用于某些windows flavor)在sshd windows服务下登录属性。

是的,有一个等同于Windows,请尝试使用xdg-open <your file>

Under the Windows command-line interpreter (cmd.exe) there is support for the start command. 在Windows命令行解释器(cmd.exe)下,支持start命令。 I know of somebody who implemented start in cygwin. 我知道有人在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" 您也可以使用以下参数cmd / c“start yourfile.file”调用cmd.exe(通常位于/cygdrive/c/windows/system32/cmd.exe中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM