为什么 jEdit 不能与“打开”一起使用? Unix 命令?
我最近在 Mac OS 10.6 系统上安装了 jEdit。我希望能够像运行 emacs 一样在终端中运行 jEdit,即“emacs FILE.NAME”。我的计划是编写一个脚本 jedit.sh 包含...
touch $1
open -a /Applications/jEdit.app $1
...其中参数是文件名。奇怪的是,jEdit 已打开,但仅打开默认的新文件,而不是所需的文件。如果我用任何其他应用程序替换“jEdit.app”,例如“TextEdit.app”,它将打开所需的文件。
我有什么遗漏的吗?为什么 jEdit 在与“打开”命令一起使用时的行为与其他应用程序不同?我该如何解决这个问题?
I recently installed jEdit on my Mac OS 10.6 system. I would like to be able to run jEdit in the terminal as I would emacs, i.e. 'emacs FILE.NAME'. My plan was to write a script jedit.sh containing...
touch $1
open -a /Applications/jEdit.app $1
...where the argument is the filename. Strangely, jEdit is opened but only with the default new file, not the desired file. If I substitute the 'jEdit.app' with any other app, say 'TextEdit.app', it opens the desired file.
Is there something I'm missing? Why doesn't jEdit behave like other apps when used with the 'open' command and how can I work around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,“open”不是标准的 UNIX 命令(我认为它是 Mac OS X 特定的命令?)。
此外,jEdit 是用 Java 编写的,因此我假设 jEdit.app 只是一个启动 Java VM 来执行 jedit.jar 的包装器(它运行
/path/to/java -jar /path/to/jedit.jar
或类似的东西,可能还有内存使用的额外选项等)。在我的 Ubuntu 系统上,jedit 包装器脚本会传递我在命令行中提到的任何文件,并且 jEdit 有效地使用它,因此问题不在于 jEdit 应用程序本身。
结论:看起来 jEdit.app 没有接受您提供的参数来将它们传递到 java 命令行...
作为解决方案,尝试将其启动为
java -jar /path/to/jedit .jar "$@"
来自您的脚本(据我所知,也不需要touch
行)。First of all, 'open' is not a standard UNIX command (I assume it's something Mac OS X-specific?).
Furthermore, jEdit is written in Java, so I assume jEdit.app is just a wrapper that starts a Java VM to execute jedit.jar (it runs
/path/to/java -jar /path/to/jedit.jar
or something like that, probably with extra options for memory usage etc.).On my Ubuntu system, the jedit wrapper script passes on whatever file I mention on the commandline, and jEdit effectively uses it, so the problem isn't with the jEdit application itself.
Conclusion: it looks like the jEdit.app doesn't take the parameters you give it to pass them on to the java commandline...
As a solution, try to start it as
java -jar /path/to/jedit.jar "$@"
from your script (AFAIK there is no need for thetouch
line either).这对我在 jEdit 5.1.0 上有效:
This works for me on jEdit 5.1.0:
转到实用程序>全局选项>一般
取消选中启动时恢复以前打开的文件(在此之前,我确保选中了“包含在命令行上指定的文件名...”)
我知道,这很奇怪,但这对我有用(mac os x Snow leopard) 、jedit 4.3.2、java 1.6.0_22)
Go to Utilities > Global options > General
Uncheck the Restore previously opened files on startup (before that, i made sure the 'include file names specified on command line...' is checked)
I know, it is strange, but this worked for me (mac os x snow leopard, jedit 4.3.2, java 1.6.0_22)