-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-dotfiles.py
More file actions
58 lines (51 loc) · 1.48 KB
/
install-dotfiles.py
File metadata and controls
58 lines (51 loc) · 1.48 KB
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
57
58
#!/usr/bin/env python3
import os
import fnmatch
import shutil
def create_symlink(dotname, directory=""):
directory_path = os.path.join(os.path.expanduser("~"), directory)
if not os.path.isdir(directory_path):
os.mkdir(directory_path)
path = os.path.join(directory_path, dotname)
if os.path.isfile(path) or os.path.islink(path):
os.unlink(path)
elif os.path.isdir(path):
shutil.rmtree(path)
os.symlink(os.path.abspath(os.path.join(directory, dotname)), path)
print("create link for %s" % path)
exclude = [
"arch-packages.txt",
"debian-packages.txt",
"*.sw*",
".git",
"*.un~",
"install-dotfiles.py",
".gitmodules",
"Makefile",
"build",
"requirements.txt",
".config",
".claude",
"get-pip.py",
".ssh",
".gnupg",
"packages.txt",
"config",
"crontab",
"nvchad",
"Brewfile",
]
for e in os.scandir("."):
if not any(fnmatch.fnmatch(e.name, p) for p in exclude):
create_symlink(e.name)
for configdir in (".config", ".ssh", ".gnupg", ".claude"):
for e in os.scandir(configdir):
if not any(fnmatch.fnmatch(e.name, p) for p in exclude):
create_symlink(e.name, configdir)
# special case for nvchad
# create symlink ~/.config/nvim/lua/custom -> nvchad/custom
dst = os.path.join(os.path.expanduser("~"), ".config/nvim/lua/custom")
if os.path.islink(dst):
os.unlink(dst)
print("create link for %s" % dst)
os.symlink(os.path.abspath("nvchad/custom"), dst)