Ubuntu – In 14.04 how to run a bash script I wrote without opening a terminal

command linescriptsunity-dash

I use terminal a lot. I wrote a script and have it in ~/blah/script.sh now. How can I run the script from Unity (Dash?)?

A long time ago I would have used ALT-F2 and typed my command, but that doesn't do what I expect now.

Maybe modifying some $PATH var somewhere so dash can find it…? I don't want to change the dir the script is in because it's in a place where I serve various scripts for reasons.


Best Answer

Simply create a .desktop file and save it in ~/.local/share/applications. In its most basic form:

[Desktop Entry]
Exec=sh /path/to/script.sh

Copy it into an empty file, save it as script.desktop in ~/.local/share/applications. After log out /in, it will appear in Dash.

If the script is executable, you can replace Exec=sh /path/to/script.sh by simply: Exec=/path/to/script.sh, or if you don't have the language extension on the script: Exec=/path/to/script


If the path to your script contains (folder-) names with spaces, you can simply escape it by putting the name between quotes. For example:

Exec=sh /path/with/'Folder with spaces'/to/script.sh

(spaces in the path to your icon can/should be left as they are)

Related Question