You can use an execute command like

sh -c 'if [ -x "%f" ]; then exec "./%f"; else exec python "%f"; fi'

Or even safer, checking it has a shebang that looks good:

sh -c 'if test -x "%f" && head -n1 "%f" | grep -q "^#!.*python"; then exec "./%f"; else exec python "%f"; fi'

Or just trusting the shebang, if any:

sh -c 'exec $(head -n1 "%f" | grep -Po "(?<=^#!).*$" || echo python) "%f"'

Geany will probably not try to read the shebang by default, because a user could select another filetype and reasonably expect his choice to be followed. We could possibly consider executing the file directly if it's executable, but it can also lead to unexpected results if that file is mistakenly marked as executable (like on some non-POSIX file systems).
For now, IMO the best solution is for you to either make your own Python filetype run Python3, or use a conditional run command like I mentioned above.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.