Skip to content

Instantly share code, notes, and snippets.

@waynew
Created August 12, 2016 19:55
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 waynew/55da13e9967ba19f95f0c2148bec69a1 to your computer and use it in GitHub Desktop.
Save waynew/55da13e9967ba19f95f0c2148bec69a1 to your computer and use it in GitHub Desktop.
#!/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