Skip to content

Instantly share code, notes, and snippets.

@waynew waynew/new-so
Created Aug 12, 2016

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.