views:

42

answers:

2

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?

+1  A: 

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 the touch line either).

JanC
I don't know jEdit, but maybe it doesn't create a new file if it's passed the name of a file that doesn't exist. Then `touch` would be needed. But I'd do it as `for x; do [ -e "$x" ] || touch "$x"; done` so as not to change an existing file's modification time and to support multiple command line arguments.
Gilles
This is not the case. Jedit will associate a new, empty buffer with the the file. When you save the file, it will create it at that time.
Ross Rogers
A: 

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)

roman