Ubuntu – Run script in Terminal via context menu (Open with Terminal)

bashcontext menufilemanagergnome-terminal

this question is simple about "Open/Run in Terminal"….

Looks Ubunutu doesn't support bash/shell-scripts the way we know from KDE and any other OS:

I tried the obvious:

  1. Right click in file manager
  2. Open with other Application…
  3. Show all applications

but there is no Terminal application listed, only "Find Online Applications". You can't even browse for a new application as you would do in any other OS.

Any ideas? I found only hacks like creating a launcher item but that's far from a solution or ideal.

To make it really clear:

I want to run any bash script accessible with the file manager via right-click, "Open with" -> "Terminal" so i can see the output. Its really like double click on a batch file under Windows and it just runs the bloody script, not closing the terminal except I wrote so in the script. So finally this is NOT about double click to run, its about the running the script through context menu as said in the title already!

thanks!

Ubuntu-x64-14.04/Unity/No Mods or tweaks.

Best Answer

The clean way would be to create a .desktop file for your script and then make it the default text editor.

  1. Create a file called /usr/share/applications/openscript.desktop with the following contents:

    [Desktop Entry]
    Name=Open script in terminal
    Exec=gnome-terminal -e "%U"
    Terminal=false
    Type=Application
    MimeType=text/plain;
    

Then, do these steps:

  • Log out/in (I don't know if it's necessary)
  • Right click on the file
  • Click on Open with...
  • Click on Another app...
  • Select "Open script in terminal"
  • You're done!