Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created September 25, 2012 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dongyuwei/3779601 to your computer and use it in GitHub Desktop.
Save dongyuwei/3779601 to your computer and use it in GitHub Desktop.
sublime text2 plugin, touch file if file does't exist before `save` file.
import sublime_plugin
import os
class TouchFile(sublime_plugin.EventListener):
def on_pre_save(self, view):
view.run_command("touch_file")
class TouchFileCommand(sublime_plugin.TextCommand):
def run(self, text):
fn = self.view.file_name().encode("utf_8")
if not os.path.exists(fn):
os.system('sudo touch ' + fn)
@dongyuwei
Copy link
Author

plugin file:
~/Library/Application Support/Sublime Text 2/Packages/User/touch_file.py

fix sublime Unable to save .... error

@maccomaccomaccomacco
Copy link

where this file must be copied?

@dongyuwei
Copy link
Author

~/Library/Application Support/Sublime Text 2/Packages/User/touch_file.py @marcoautiero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment