Created
August 12, 2016 19:55
-
-
Save waynew/55da13e9967ba19f95f0c2148bec69a1 to your computer and use it in GitHub Desktop.
This file contains 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 python3 | |
import os | |
import sys | |
import logging | |
logging.basicConfig(level=logging.WARNING) | |
if len(sys.argv) < 2: | |
question_url = input('Question URL: ') | |
else: | |
question_url = sys.argv[1] | |
question_num, question_title = question_url.split('questions/')[1].split('/', 1) | |
question_dir = os.path.expanduser( | |
'~/programming/so/{}-{}'.format(question_num, question_title) | |
) | |
filename = os.path.join(question_dir, 'test.py') | |
os.makedirs(question_dir, exist_ok=True) | |
with open(filename, 'w') as f: | |
pass | |
print('Run the following:\n\tvim {}'.format(filename)) | |
try: | |
os.system('tmux set-buffer "vim {}"'.format(filename)) | |
except: | |
logging.exception('Error setting tmux buffer') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment