How To Stop Scripts From Opening in Text Editor When Double Clicked
Under normal circumstances, double clicking on a shell script — for an example a .sh file — the first expectation is whatever file you clicked on will be executed. But if you unintentionally change the double click behavior on your Debian for script files or you running on an Ubuntu OS and have Nautilus as your file manager, chances are that every time you try to execute a script by double-clicking on it, the file opens in a Gedit text editor instead even if it has executed permission granted to it. This can be quite frustrating and though there is already a well-used solution to this problem — running it in the terminal — but what about usual way of just double clicking on the freaking thing to have it execute?
We are here to tell you that you shouldn’t worry as this tutorial will walk you through on how to fix the said problem in Ubuntu.
First thing you need to know is that the file manager of the previous versions of the Ubuntu OS will ask you if you want to execute a script or open it for editing every time you double click on it, Canonical made a mess with the feature in their recent releases setting the default to directly open in a text editor instead. To change this, make your way to the file manager from the top menu and look for Preference.
When you reach File Preferences, move on to the Behavior tab and you should see an option for “Executable Text Files”.
Here the default setting is set at “View Executable Files When They Are Opened”. It is advised to change it to “Ask Each Time” to give you some sort of control over the files you wish to execute or you can set the default setting to just execute.