How to change default action when running a .sh file?

Open Nautilus, then go to Edit -> Preferences. Open Behavior tab and you'll find the options to set the file manager behavior when you open executable text files.


Making each .desktop files for Run in Terminal or Display or Run , you can set default action for each sh files.

Execute authority is given to each .desktop files.

For example:

  • Run in terminal

Filename : sample-term.desktop

[Desktop Entry]
Type=Application
Name=Run in terminal
Exec='/fullpath_to_script/sample1.sh'
Terminal=true

Click this file, it will be able to run sample1.sh in terminal.

  • Display

Filename : sample-edit.desktop

[Desktop Entry]
Type=Application
Name=Edit script
Exec=gedit '/fullpath_to_script/sample2.sh'
Terminal=false

Click this file, it will be able to edit sample2.sh by gedit.

  • Run

Filename : sample-run.desktop

[Desktop Entry]
Type=Application
Name=Run script
Exec='/fullpath_to_script/sample3.sh'
Terminal=false

Click this file, it will be able to run sample3.sh.