3

I'm challenging myself for the next few weeks to use a terminal emulator as my main file manager.

I've run into a question: how do I open a file (e.g. an Inkscape .svg) in it's GUI program from the command line? I know I can use:

inkscape ./Design.svg &

to move it to the background, but it's still a child of the gnome-terminal process (and dies with it). Additionally, any debug warnings, etc will be output to that terminal (interrupting and annoying me).

How does a file manager like Nautilus split off launched editor processes in a way that they are no longer attached at all?

How can I do that from my terminal?

Robin
  • 282
  • 4
    inkscape Design.svg & disown or in ZSH inkscape Design.svg &| or &! to save typing disown. – thrig Jan 15 '16 at 19:44

1 Answers1

4

Various ways of accomplishing this are discussed, along with the merits and drawbacks of each, in the article "Running bash commands in the background properly". Based mostly on that article and also my own reading of the POSIX specs for nohup, the most portable way to accomplish what you want is with:

nohup inkscape ./Design.svg >/dev/null 2>&1 &

This doesn't actually disown the process—your terminal is still the parent process. However,

  1. The inkscape process won't die if your terminal dies, and
  2. You won't see any output on your terminal,
  3. The file nohup.out won't be created in your home directory, as it would if you removed the redirects to /dev/null. (See the nohup documention for explanation of this file.)

If you're using bash and don't care about POSIX portability so much as simplicity, then the simplest way is, as @thrig noted in the comments:

inkscape ./Design.svg & disown

There are several options you can use with disown, although you don't need them for this use case. Type in help disown to see the other options available.

Wildcard
  • 36,499