Summary: How to set Run in Terminal
as the default Nautilus doubleclick action?
I wish to run an interactive script by doubleclicking it. To interact with it, I have to see it run.
If I gsettings
set org.gnome.nautilus.preferences executable-text-activation
to ask
, then it gives me a choice; Run in Terminal
does what I want; Run
doesn't, since when the script needs to ask me something, it just hangs. However, I don't want to have to click the Run in Terminal
every time. I want it to do that by default. I've done it before somehow.
I tried to gsettings
set org.gnome.nautilus.preferences executable-text-activation
to launch
; however, that simply does Run
as the default; I don't see a way to make it Run in Terminal
by default.
I have also tried inserting a gnome-terminal
command. This successfully pops up a terminal window (even when simply Run
); however, I then somehow need to send all the commands to that terminal window.
Alternatively, I know how to send (just) the interactive portion of the script to that terminal, which would work for me; however, in that case I need the script to halt until the interactive portion of it finishes, and then resume the execution. Typically, this can be accomplished using the wait
command; as is, the gnome-terminal
command seems to work as gnome-terminal&
instead, in that it relinquishes control to the bash script as soon as it is launched.
I've read through almost 10 duplicates of the thread How do I run executable scripts in Nautilus? (including other sites), and still cannot find my answer.
Any other workarounds will be appreciated.
Best Answer
Not literally what you asked for, still an elegant option I believe:
Add a right-click option to run a selected script in terminal
Create a small script:
Save it as
run_interminal.sh
in~/.local/share/nautilus/scripts
. Create the directory if it doesn't exist.That's it. Select a script and choose Scripts --> runinterminal.sh:
Alternatively; drag/drop- run in terminal
Drag an (executable) script over a launcher to have it run in the terminal:
Copy the code below into an empty file and save it on your desktop as
run_script.desktop
Make it executable
That's it. Now when dragging an executable script on to the icon, it will run in (gnome-) terminal.
Important note
As mentioned, the script
run_interminal.sh
needs to be executable to appear in the menu.As it is, the script to run also needs to be executable.
run_interminal.sh
can easily be set to automatically make the targeted script executable or call an interpreter. If that is needed, please mention.