1

When I open a file with atom through ranger and than close the terminal which executes ranger, it causes the atom editor to close too, my configuration file looks like:

user@computer ~ $ cat ~/.config/ranger/rifle.conf
ext c|cpp|h|md|txt = xdg-open "$@"

I also tried it by explicitly defining atom as the default application inside ranger:

user@computer ~ $ cat ~/.config/ranger/rifle.conf
ext c|cpp|h|md|txt = atom "$@"

This however has the same effect as described above.

Q: How do I prevent the atom-editor from closing when I close ranger?

EDIT:
I open ranger with the shortcut [ctrl]+[alt]+[r], which executes the following command:
gnome-terminal -x ranger

PatrickSteiner
  • 581
  • 3
  • 10
  • 20

1 Answers1

0

Your issue sounds like Ranger is not disowning and/or nohup'ing the child processes so that they're disconnected from it properly, so that they'll persist when/if Ranger is exited. If you look at the integration with other programs page of Ranger you'll see an example like this:

If using Xnview with rifle, and despite forking with flag 'f', it crashes compiz/unity, try this:

mime ^image, has xnview, X, flag f = setsid xnview "@$" &> /dev/null 2>&1 & disown

The key item in that example is the & disown. I'd try putting that at the end of your example:

ext c|cpp|h|md|txt = atom "$@" &> /dev/null 2>&1 & disown

References

slm
  • 363,520
  • 117
  • 767
  • 871
  • Thanks, unfortunately this only works when i first open a terminal, than insert `mime ^image, has atom, X, flag f = setsid atom "@$" &> /dev/null 2>&1 & disown` and at least execute the command `ranger`. However I do launch ranger with a shortcut which executes the command `gnome-terminal -x ranger`, so I tried to adapt it like `gnome-terminal -e 'sh -c "mime ^image, has atom, X, flag f = setsid atom "@$" &> /dev/null 2>&1 & disown; ranger"'`. But that doesn't work, i.e. atom still closes by exiting ranger. Any idea? – PatrickSteiner Aug 14 '18 at 12:30
  • 1
    @PatrickSteiner - sorry i showed this only to highlight the `& disown` at the end. I've updated my A'er to highlight this. – slm Aug 14 '18 at 12:47
  • I see. Tried it this time as you mentioned with `ext c|cpp|h|md|txt = atom "$@" &> /dev/null 2>&1 & disown` and only with `ext c|cpp|h|md|txt = atom "$@" & disown`. Still the same result :/ – PatrickSteiner Aug 14 '18 at 13:19
  • @PatrickSteiner - another variation to try - `mime ^video, has mpv.exe, X, flag f = mpv.exe --fs -- "$@" > /dev/null 2>&1 &`. You'll have to play with this unfortunately. I don't have Ranger set up - https://github.com/ranger/ranger/issues/917. Your issue is the invokes of executables is not being disconnected properly from the parent proc Ranger. – slm Aug 14 '18 at 13:24
  • Look at the Ranger examples and I'd encourage you to raise your issue w/ the upstream Ranger project - https://github.com/ranger/ranger. You can create issues there. If you need help doing this LMK and I can raise the issue on your behalf. – slm Aug 14 '18 at 13:26
  • @PatrickSteiner - Also as I research this more and more, your issue might in fact lie w/ `rifle` - https://jlk.fjfi.cvut.cz/arch/manpages/man/rifle.1. – slm Aug 14 '18 at 13:33
  • 1
    @PatrickSteiner - as a completely different take on this you could try using `open_with` as described here - https://unix.stackexchange.com/questions/356732/ranger-open-with-without-suspending. – slm Aug 14 '18 at 13:39
  • 1
    `:open_with atom f` would work. The flag `f` forks the process so that i can close ranger, while atom still stays open. But that isn't very convenient, in the long run, when you have to type every time the program's name. – PatrickSteiner Aug 14 '18 at 14:18