-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvi_changed_files.py
executable file
·45 lines (31 loc) · 973 Bytes
/
vi_changed_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import commands
import os
from subprocess import call
EDITOR = os.environ.get('EDITOR','vim') #that easy!
modified_op = commands.getstatusoutput(
'git status --u=no | grep modified: | awk \'{print $2}\'')
new_files_op = commands.getstatusoutput(
'git status --u=no | grep \"new file:\" | awk \'{print $3}\'')
list_of_files=[]
if modified_op[0] == 0:
list_of_files.extend(modified_op[1].split('\n'))
if new_files_op[0] == 0:
list_of_files.extend(new_files_op[1].split('\n'))
#Display
count = 0
print ''
for file in list_of_files:
print '[' + str(count) + '] ' + file
count = count + 1
while True:
print ''
selection = input('Select the file: ')
print ''
print 'Opening ' + list_of_files[selection]
print ''
confirm = raw_input("Continue y/n : ")
if confirm.lower() == 'y' or confirm.lower() == 'yes':
call ([EDITOR, list_of_files[selection]])
break
continue