Lets say I want to execute a simple Python script from Nautilus, the default file manager of GNOME:
#!/usr/bin/python3
print("Hello")
Of course the aim is to interact with selected files in Nautilus, but I want to keep it simple.
I save the script to the folder ~/.local/share/nautilus/scripts/
and then I can execute it from the right click context menu:
How can I execute this nautilus script inside gnome-terminal and keep the terminal opened at the end of the script?
I have found that I can achieve what I want to do using two script files.
1)
Hello.sh
to open gnome-terminal (and potentially leave it open)The first script file
~/.local/share/nautilus/scripts/Hello.sh
will appear in Nautilus script context menu and will open gnome-terminal in order to execute.Hello.py
:To force the terminal window to stay open after execution (to see output or for debugging purpose if it fails), tweak it as follow to make gnome-terminal execute
bash
at the end:2)
.Hello.py
to execute the actual scriptThen, the second script file
~/.local/share/nautilus/scripts/.Hello.py
will be executed inside the gnome-terminal windows opened previously but will be hidden from nautilus script context menu.