Update stow.py
This commit is contained in:
parent
44f2ec02d4
commit
d223857265
3 changed files with 14 additions and 17 deletions
27
bin/stow.py
27
bin/stow.py
|
@ -10,13 +10,10 @@ DOTS = os.getenv("DOTS", os.getcwd())
|
|||
def stow(pkg, stow_dir):
|
||||
pkg_path = os.path.join(DOTS, pkg)
|
||||
|
||||
for root, dirs, files in os.walk(pkg_path):
|
||||
files = [f for f in files if not f.startswith(".")]
|
||||
dirs[:] = [d for d in dirs if not d.startswith(".")]
|
||||
|
||||
for root, _, files in os.walk(pkg_path):
|
||||
symlink_dir = root.replace(pkg_path, stow_dir)
|
||||
if not os.path.exists(symlink_dir):
|
||||
os.makedirs(symlink_dir)
|
||||
|
||||
os.makedirs(symlink_dir, exist_ok=True)
|
||||
|
||||
for file in files:
|
||||
source = os.path.join(root, file)
|
||||
|
@ -30,14 +27,14 @@ def stow(pkg, stow_dir):
|
|||
def get_pkgs():
|
||||
pkgs = []
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
for pkg in sys.argv[1:]:
|
||||
if os.path.isdir(os.path.join(DOTS, pkg)):
|
||||
pkgs.append(pkg)
|
||||
else:
|
||||
print(f"The package {pkg} is not a valid package.", file=sys.stderr)
|
||||
else:
|
||||
pkgs = [d for d in os.listdir(DOTS) if not d.startswith(".")]
|
||||
for file in os.listdir(DOTS):
|
||||
if file == ".git":
|
||||
continue
|
||||
|
||||
if os.path.isfile(os.path.join(DOTS, file)):
|
||||
continue
|
||||
|
||||
pkgs.append(file)
|
||||
|
||||
return pkgs
|
||||
|
||||
|
@ -51,6 +48,4 @@ def get_stow_dir(pkg):
|
|||
|
||||
if __name__ == "__main__":
|
||||
for pkg in get_pkgs():
|
||||
if pkg in ["docs"]: continue
|
||||
|
||||
stow(pkg, get_stow_dir(pkg))
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
[push]
|
||||
autoSetupRemote = true
|
||||
|
||||
[pull]
|
||||
rebase = true
|
||||
|
||||
[alias]
|
||||
s = status -u
|
||||
a = add -A
|
||||
|
|
1
zsh/.gitignore
vendored
1
zsh/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
zsh-secrets
|
Loading…
Reference in a new issue