Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a script on Linux just by double clicking it

I have a script written (which are basically the commands for the terminal for Ubuntu) on a file. Yes, the code starts with

#!/bin/bash

How do I run this script just by double clicking it? It can be run using the terminal but I want to make it more accessible through my desktop.

I was just trying to mimic a *.bat file on windows. A *.bat file on windows contains series of scripts operable on command prompt and executable just by double clicking on it.

like image 808
pnkjmndhl Avatar asked Feb 04 '17 19:02

pnkjmndhl


People also ask

How do I run a shell script in double click?

macOS - How to execute a shell script with a double clickMost of use use the extension ". sh" for a shell script, but this could be associated with a text editor like BBEdit (highly recommended and there is a free version). So instead of running the script, it will open it in your text editor.


2 Answers

Source https://askubuntu.com/a/286651/113065

Edit -> preferences -> Behavior -> Executable Text Files = Run ...

It should run, but you can't see output.

like image 116
Amr Lotfy Avatar answered Sep 17 '22 15:09

Amr Lotfy


Follow these steps:

  • Hit Alt+F2, type dconf-editor and hit ``Enter.

  • In dconfg-editor goto: org ➤ gnome ➤ nautilus ➤ preferences

  • Click on executable-text-activation and from drop down menu select:

launch: to launch scripts as programs.

OR

ask: to ask what to do via a dialog.

Close dconf-editor Thats it!

like image 32
orvi Avatar answered Sep 18 '22 15:09

orvi