3

Recently I found out a new very useful command. It is:

gnome-open

or

xdg-open

or just

open

on mac.

It opens file or directory in by default specified program.

But, in the event that I need to open a file in an already running redactor (I mean send the file to a running processes somehow) I have no solution. I wonder if there is any way to achieve that or if it is possible to write a script that can do that.

For example if I want to send it to an already running instance of eclipse.

Kind of drag-and-drop through commandline.

Caleb
  • 70,105
Pol
  • 133
  • 5

4 Answers4

2

Did you try

eclipse --launcher.openFile <absolute path of file to open>

Eclipse OpenFile Feature.

Mikel
  • 57,299
  • 15
  • 134
  • 153
  • 1
    Yep.. already tried. it is trying to open in new instance of eclipse. But from the link that you provided it has to open it in running instance. I'm using ubuntu and eclipse Version: 3.5.2. Perhaps i need to upgrade the version of eclipse? – Pol Apr 24 '11 at 02:31
2

This kind of control is program specific. Different editors will support it in different ways or won't support it at all. For example, Eclipse uses the command mentioned by Mikel. Vim or GVim, which is my preferred editor supports a sophisticated mechanism for remote control beyond simply opening a file in an existing Window. To simply load a file into an existing session:

gvim --remote file1.c file2.c

It will also start an existing session if it can't find an existing one. You can also name specific GVim windows to target them and do remote scripting of existing GVim windows. I'm sure Emacs has similar functionality.

penguin359
  • 12,077
1

Most programs that accept new file or other object input will have a separate binary to talk to the main one, usually known as a remote. I don't know about eclipse, but for example gimp-remote allows you to open new images in the already running application.

Caleb
  • 70,105
0

I tried your said "gnome-open" command from command-line, And It opens the underlying file in an associated application.

e.g. I execute the command "gnome-open /etc/X11/xorg.conf", it opens in gedit.

And the from command-line, I again the execute the command, "gnome-open /etc/passwd". Now this file is also get opened in the same instance of gedit.

So I guess, this is what you are looking for.

You have to use "gnome-open" command only.

SHW
  • 14,786
  • 14
  • 66
  • 101