-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwritefile.py
More file actions
30 lines (20 loc) · 802 Bytes
/
writefile.py
File metadata and controls
30 lines (20 loc) · 802 Bytes
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
import sys
import os
def writeToShell():
user = os.path.dirname(os.path.realpath(__file__)).split('/')[2]
with open('/Users/' + user + "/.zshrc", 'a') as f:
f.writelines(['\n'])
f.writelines(['source ~/.GitSetUpForTerminal/commands.sh'])
def writeNew():
user = os.path.dirname(os.path.realpath(__file__)).split('/')[2]
writing = ["#!/bin/bash","function %s() {" % (sys.argv[1]), "\tpython3 /Users/" + user + "/Documents/" + sys.argv[1] + "/main.py $1 $2 $3 $4 $5 $6", "}"]
with open("/Users/" + user + "/" + sys.argv[1] + ".sh", "w") as f:
for line in writing:
f.writelines([line + "\n"])
with open('/Users/' + user + "/.zshrc", 'a') as f:
f.writelines(['\n'])
f.writelines(['source ~/' + sys.argv[1] + '.sh'])
if sys.argv[1] == "install":
writeToShell()
else:
writeNew()