Skip to content

Instantly share code, notes, and snippets.

@idleberg
Last active February 24, 2024 02:17
Show Gist options
  • Save idleberg/03bc3766c760bb4b81e3 to your computer and use it in GitHub Desktop.
Save idleberg/03bc3766c760bb4b81e3 to your computer and use it in GitHub Desktop.
Make files of Sublime Text package executable, runs on installation/upgrade
# https://gist.github.com/idleberg/03bc3766c760bb4b81e3
import os, stat, sublime, sublime_plugin
# Array of files, relative to package directory
files = [
'my-script.sh'
]
def plugin_loaded():
from package_control import events
# Get name of package folder
me = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
if (events.install(me) or events.post_upgrade(me)) and os.name is 'posix' or 'mac':
for file in files:
# Concat full path
file_path = sublime.packages_path() + '/' + me + '/' + file
# Change permissions, if file exists
if os.path.isfile(file_path):
st = os.stat(file_path)
os.chmod(file_path, st.st_mode | stat.S_IEXEC)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment