I'm looking for a way to open a .py file with Python in a terminal every time a file is double-clicked in a GUI file manager, like in Windows. How would I go about doing this?
For Ubuntu 13.10
I'm looking for a way to open a .py file with Python in a terminal every time a file is double-clicked in a GUI file manager, like in Windows. How would I go about doing this?
For Ubuntu 13.10
This works in Unity & Gnome, similar things are there for other desktop environments.
Right click on the file, and go to Properties, and permissions. Make sure this is ticked :
(You need this ticked anyway for the file to run in terminal, or be 'executed', it is the same as running
chmod +x /PATH/TO/FILE
)And make sure this, under the Behaviour tab, in Nautilus file manager's preferences, is set to this:
Now every time you click on it, you should get:
Run in Terminal, you can guess.
Display opens it in the default text editor defined in 'Open With...'. in the files preferences.
Run runs it in the background, with no terminal. This is also what happens if you select 'Run executable text files when they are opened' above.
Here is a fix to stop it closing instantly - go to Profile Preferences, and under Title and Command, set:
, Now when you run a script like this :
(Remember the shebang
#!/usr/bin/python
line, otherwise it won't be interpreted correctly. You can also use#!/usr/bin/env python
.)It stay open a while, then you should get something like: