-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·56 lines (46 loc) · 1.31 KB
/
install
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
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
from shutil import move
import os
import os.path as path
BACKUP = ".backup"
# schema is dest : src to avoid duplicate keys
SYMLINKS = {
".gitconfig": "git/.gitconfig",
".config/nvim": "nvim",
".zshrc": "zsh/.zshrc",
".tmux.conf": "tmux/tmux.conf",
".config/alacritty": "alacritty",
".config/zathura": "zathura",
".config/fish": "fish",
}
POSTINSTALL = [
# install tmux plugin manager
"""
if [ ! -d ~/.tmux/plugins/tpm ]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
""",
# install omf
"curl -L https://get.oh-my.fish | fish"
]
def backup(src):
if path.exists(src) and not path.islink(src):
newloc = path.join(os.getcwd(), BACKUP, path.basename(src))
print(" -- Backing up: {} -> {}".format(src, newloc))
move(src, newloc)
def link(src, dst):
src = path.abspath(path.join(os.getcwd(), src))
dst = path.abspath(path.join(path.expanduser('~'), dst))
backup(dst)
print("Linking: {} -> {}".format(src, dst))
if path.islink(dst):
os.remove(dst)
os.symlink(src, dst)
# install
if not path.isdir(BACKUP):
print("Making backup dir...")
os.mkdir(BACKUP)
for (dest, src) in SYMLINKS.items():
link(src, dest)
for cmd in POSTINSTALL:
os.system(cmd)