Ubuntu: Nautilus - Open with Sublime - Open in new window



Question:

In Nautilus on Ubuntu Desktop 14.04, when I choose "open with" and then select "Sublime", the document will always open in any existing instance you have open. If I use the CLI and call subl --new-window [path to file] then I get the desired behaviour.

How can I add the --new-window argument to the call that nautilus is executing to open with Sublime?


Solution:1

The easiest is just to edit sublime's .desktop & add the -n option to the Exec= line. This works well when one has disabled sublime's default of remembering the last session.

To do so just run sudo nano /usr/share/applications/sublime-text.desktop & add -n to the Exec= line so it looks like -

Exec=/opt/sublime_text/sublime_text -n %F

Also to note - on some systems sublime will cause cursor run on when used from the context menu. If that's the case while the .desktop is open to edit scroll down to the StartupNotify=true line & make it StartupNotify=false. This will prevent cursor run on..

(- for those not used to nano - after editing go -

ctrl+o

press enter key on keyboard

ctrl+x


Solution:2

It is a simple question but a tricky one to answer. I haven't used Sublime myself but problem is similar with Gedit as well. If you prefer you can use Nautilus actions to add a context-menu item. Install it through Software center.

If you want to create Nautilus script you will have to use $@ characters as substitution of environment variable NAUTILUS_SCRIPT_SELECTED_FILE_PATHS:

#!/bin/bash  for i in "$@"; do       gedit --new-window "$i" & xdotool search --sync --onlyvisible --name "$i" windowactivate  done  exit 0  

The -xdotool here is to raise windows because they all runs in the background but you can alter the behavior the way you are familiar with, spread them around or just live it alone the way it is.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »