Skip to content

Instantly share code, notes, and snippets.

@yvess
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yvess/11392650 to your computer and use it in GitHub Desktop.
Save yvess/11392650 to your computer and use it in GitHub Desktop.
import os
import editor
"""
save this file in the root directory of your script library, and add
the action work_on
"""
WK_PATH = './_working_on_'
WK_CONTENT = '''import editor
editor.open_file('%s')
'''
if True: # if len(sys.argv) == 1 and sys.argv[1] == 'add'
file_path = '/private%s' % editor.get_path()
cwd_path = os.getcwd()
relative_path = file_path[len(cwd_path)+1:]
file_segments_3 = ':'.join(relative_path.split('/')[-3:])
if not os.path.exists(WK_PATH):
os.mkdir(WK_PATH)
wk_file = '%s/%s/%s' % (cwd_path, WK_PATH, file_segments_3)
wk_file = wk_file.replace('/./', '/')
if not os.path.exists(wk_file):
# os.link(file_path, wk_file) # hardlinks don't work
f = open(wk_file, 'w+')
f.write(WK_CONTENT % file_path)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment