Last active
August 29, 2015 14:01
-
-
Save persquare/8ba4dfee1a64b8a98aa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python -S | |
| #encoding: utf-8 | |
| # For TM2:TextTasks | |
| # Settings: | |
| # Input::Line::Text | |
| # output::Insert after input::Snippet | |
| import os | |
| import sys | |
| import re | |
| tm_support_path = os.environ['TM_BUNDLE_SUPPORT'] | |
| if tm_support_path not in sys.path: | |
| sys.path.insert(0, tm_support_path) | |
| import exit_codes as exit | |
| if os.environ.get('TM_SELECTED_TEXT', None): | |
| # If there is a selection I can't get access to the line?! Bail. | |
| exit.discard() | |
| line = os.environ.get('TM_CURRENT_LINE') | |
| line = line.rstrip('\r\n ') | |
| col = int(os.environ.get('TM_LINE_INDEX')) | |
| match = re.match(r'^(\s*).*$', line) | |
| if not match: | |
| # Not a task => just insert newline | |
| sys.stdout.write('\n- ${0}') | |
| else: | |
| indent = match.group(1) | |
| sys.stdout.write('%s\n- ${0}' % indent) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment