-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
47 lines (37 loc) · 1.26 KB
/
index.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
46
47
import os
import json
# import code
# import vscode
import subprocess
def code():
if os.system("code --version > /dev/null 2> /dev/null") == 32512:
code = "export PATH=\"$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin\""
with open(os.path.expanduser("~/.zshrc"), "a") as f:
f.write(code)
subprocess.call("source ~/.zshrc",shell=True,executable='/bin/zsh')
def vscode():
code()
os.system("code --list-extensions > list-extensions.txt")
# Get the user name
user = os.environ["USER"]
# read the file config.json
with open("config.json", "r") as f:
config = f.read()
config = json.loads(config)
folders_list = config["symbolic_links"]
# Create the symbolic links
for folder in folders_list:
target = "/goinfre/" + user + "/" + folder["target"]
if not os.path.exists(target):
os.makedirs(target)
source = folder["source"]
if not os.path.exists(os.path.expanduser(source)):
os.symlink(target, os.path.expanduser(source))
# Install the extensions
code()
if not os.path.exists("list-extensions.txt"):
vscode()
with open("list-extensions.txt", "r") as f:
extensions = f.read().splitlines()
for extension in extensions:
os.system("code --install-extension " + extension)