Skip to content

Instantly share code, notes, and snippets.

@Benhgift
Last active November 21, 2018 03:32
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 Benhgift/1a33bca248c983286ee89cd6b8a9545c to your computer and use it in GitHub Desktop.
Save Benhgift/1a33bca248c983286ee89cd6b8a9545c to your computer and use it in GitHub Desktop.
open some changed files on branch, compared to master
#!/usr/bin/env python3
from subprocess import getoutput
import os
import re
def main():
files = get_files()
if not files[0]: return error()
nums = file_nums_to_open(files)
file_dict = get_file_dict(files)
for num in nums:
os.system('gvim ' + file_dict[num])
def error():
print('no files changed on this branch')
def get_files():
return getoutput('git diff master --name-only').split('\n')
def file_nums_to_open(files):
print_files(files)
nums = input('\ntype file numbers to open\n')
return map(int, re.findall(r'\d+', nums))
def print_files(files):
for i, f in enumerate(files):
if i < 10:
print(i, '', f)
else:
print(i, f)
def get_file_dict(files):
return { i: f for i, f in enumerate(files) }
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment