-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_switch.pyw
29 lines (24 loc) · 905 Bytes
/
email_switch.pyw
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
import os
from yaml import safe_load
from win10toast import ToastNotifier
class EmailSwitch:
def __init__(self):
with open("config.yml") as config:
self.emails = safe_load(config)
self.toaster = ToastNotifier()
def switch(self):
stream = os.popen("git config user.email")
current_email = stream.read().strip()
if current_email == self.emails[0]:
os.popen(f"git config --global user.email {self.emails[1]}")
self.toaster.show_toast(
"Git Email Switch", f"Git email is now {self.emails[1]}"
)
else:
os.popen(f"git config --global user.email {self.emails[0]}")
self.toaster.show_toast(
"Git Email Switch", f"Git email is now {self.emails[0]}"
)
if __name__ == "__main__":
email_switch = EmailSwitch()
email_switch.switch()