mirror of
https://github.com/xHyroM/dotfiles.git
synced 2024-11-22 14:41:05 +01:00
feat: goog sync
This commit is contained in:
parent
5c9f8b7ca4
commit
05c1191be2
1 changed files with 29 additions and 0 deletions
|
@ -1,2 +1,31 @@
|
||||||
|
from glob import glob
|
||||||
|
import shutil
|
||||||
|
import os
|
||||||
|
|
||||||
def sync(stuff: list[str]):
|
def sync(stuff: list[str]):
|
||||||
|
for pattern in stuff:
|
||||||
|
normalized_pattern = pattern.removeprefix("~")
|
||||||
|
normalized_pattern = normalized_pattern.removeprefix("/")
|
||||||
|
pattern_prefix = pattern[:2] if pattern.startswith("~") else pattern[0]
|
||||||
|
overwrite = False
|
||||||
|
|
||||||
|
for path in glob(normalized_pattern, recursive=True):
|
||||||
|
|
||||||
|
system_path = os.path.expanduser(pattern_prefix + path)
|
||||||
|
if os.path.isdir(path):
|
||||||
|
os.makedirs(system_path, exist_ok=True)
|
||||||
|
else:
|
||||||
|
print(f"Copying {path} to {system_path}")
|
||||||
|
if os.path.exists(system_path) and not overwrite:
|
||||||
|
print(f"Path {system_path} already exists. Do you want to overwrite it with {path}? y/n/a")
|
||||||
|
|
||||||
|
ask = input()
|
||||||
|
if ask not in ("y", "a"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
overwrite = ask == "a"
|
||||||
|
|
||||||
|
shutil.copy2(path, system_path)
|
||||||
|
|
||||||
|
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue