diff options
| author | Thomas Schneider <qsx@chaotikum.eu> | 2020-01-26 13:00:15 +0100 |
|---|---|---|
| committer | Thomas Schneider <qsx@chaotikum.eu> | 2020-01-26 13:00:15 +0100 |
| commit | 6d68935a4580864911ba5745a1551bae9d85801d (patch) | |
| tree | 1a353bfbef770f4c7407532df49da6bc896abf8d /install.py | |
| parent | 7f6494656830de52e997fc4d8e3f8ba465fca6eb (diff) | |
| parent | a6e39c04a7cd31dc9db5018455fa286284ee84ac (diff) | |
Merge remote-tracking branch 'origin/main' into neptun
Diffstat (limited to 'install.py')
| -rwxr-xr-x | install.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/install.py b/install.py new file mode 100755 index 0000000..2ade691 --- /dev/null +++ b/install.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import os +import sys +from pathlib import Path + +here = Path(__file__).parent.resolve() +home = Path.home().resolve() + +exit = 0 + +for f in here.glob("dot.*"): + dst = home / Path( + f.name[3:].replace("--", "\ufffd").replace("-", "/").replace("\ufffd", "-") + ) + try: + src = f.relative_to(dst.parent) + except ValueError: + src = os.path.relpath(str(f), str(dst.parent)) + + dst.parent.mkdir(parents=True, exist_ok=True) + + try: + dst.symlink_to(src) + except FileExistsError: + if not (dst.parent / src).samefile(dst): + print("{} exists and does not link to {}".format(dst, src)) + exit = 1 + +sys.exit(exit) |
