6

They will only open in a text editor. "Open With" doesn't offer an option to execute. The shell scripts are +x so they should run normally.

As a workaround, I set them to be opened with the terminal emulator, but it is not ideal.

Eric Blank
  • 111
  • 1
  • 2
  • 4
  • 1
    It's different question since it's about XFCE and the answers are all about Gnome and nautilus. – jcubic Jan 14 '17 at 20:33
  • 1
    The answer about Thunar is [here](https://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows/871986#871986). – Marco Apr 18 '17 at 14:20
  • @Marco- Also, [here](https://askubuntu.com/a/1170255/925128) on how to achieve the purpose with custom actions in Thunar (without re-enabling that "risky" feature). – cipricus Sep 02 '19 at 12:40
  • You can make `.sh` files execute on double click without a terminal window by _right click on a file -> Open With Other Application -> Use custom command -> type "bash" in the input field_ then tick "Use as default for this kind of file", and press "Open" – Klesun Nov 30 '19 at 17:40

1 Answers1

-1

Even when marked as executable, the system doesn't know what to use to interpret the script. If it is a POSIX shell script, add this line to the very beginning of your script:

#!/bin/sh

Should it require bash or some other shell, use e.g. for bash

#!/bin/bash

The same applies to other executable text files, such as python programs:

#!/usr/bin/python
s3lph
  • 14,118
  • 11
  • 57
  • 82
  • 1
    I have that line in the script and Thunar open the file in text editor. – jcubic Jan 14 '17 at 20:23
  • Did you make your script executable? I.e. `chmod +x `? – s3lph Jan 15 '17 at 20:37
  • 1
    Yes, I've found the solution and added answer to the duplicate question [exec by clicking in Xfce](http://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows#answer-871986) – jcubic Jan 16 '17 at 09:37