-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotsync.py
More file actions
40 lines (36 loc) · 1.04 KB
/
dotsync.py
File metadata and controls
40 lines (36 loc) · 1.04 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
from pathlib import Path
import shutil
dest_dir: Path = Path.home()
dotfile_dir: Path = Path(dest_dir, "dotfiles")
dir_list: list[str] = [
".config/wezterm",
".config/yazi",
".config/nvim",
".config/bat",
".config/fish",
]
for d in dir_list:
print(f"Symlinking '{d}'")
try:
if Path(dest_dir, d).is_symlink():
Path(dest_dir, d).unlink()
else:
shutil.rmtree(Path(dest_dir, d), )
Path(dest_dir, d).symlink_to(
Path(dotfile_dir, d),
target_is_directory=True,
)
print(f"Symlinked '{d}' to '{Path(dotfile_dir, d)}'")
except (FileNotFoundError, OSError):
pass
for f in dotfile_dir.glob(".*"):
if f.is_file():
try:
Path(dest_dir, f.name).unlink()
except FileNotFoundError:
pass
try:
Path(dest_dir, f.name).symlink_to(Path(dotfile_dir, f.name))
print(f"Symlinked '{f.name}' to '{Path(dotfile_dir, f.name)}'")
except (FileNotFoundError, OSError):
pass