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?

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


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


  • 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
  • 1
    @PatrickSteiner - as a completely different take on this you could try using open_with as described here - unix.stackexchange.com/questions/356732/…. – 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.