Ubuntu – How to change default action when running a .sh file

gnomenautilusscripts

Every time I want to run a .sh file, Ubuntu asks whether I want to Run in Terminal/Display/Run it. Is there a way to set default action for some sh files?

— I am using Ubuntu 12.04 without any special changes.

Best Answer

  • 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.