How Do I Make .py Files Executable By Default On Mac Os?
I know that you can do 'chmod +x filename.py' to make the file executable on mac but is there a way I can change some setting so that happens by default when I create a filename wi
Solution 1:
I am not sure how sensible an idea this is, but you can achieve it using a "filesystem watcher" such as fswatch
(the macOS equivalent of Linux's inotifywait
).
So, you can use homebrew to install fswatch
like this:
brew install fswatch
Then, say you wanted to monitor all filesystem events under your HOME
directory that pertain to Python files and involve file creation, you could run:
fswatch -0 -E --event Created -e ".*" -i ".py$"$HOME | xargs -0 -n1 chmod +x
You won't see anything, but as soon as you create a file ending in .py
, it will run chmod +x
on that file to make it executable.
Solution 2:
using Automator, create an application that runs a shell script that runs python, and set the default application for opening .py files.
Post a Comment for "How Do I Make .py Files Executable By Default On Mac Os?"