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):
|
def stow(pkg, stow_dir):
|
||||||
pkg_path = os.path.join(DOTS, pkg)
|
pkg_path = os.path.join(DOTS, pkg)
|
||||||
|
|
||||||
for root, dirs, files in os.walk(pkg_path):
|
for root, _, 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(".")]
|
|
||||||
|
|
||||||
symlink_dir = root.replace(pkg_path, stow_dir)
|
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:
|
for file in files:
|
||||||
source = os.path.join(root, file)
|
source = os.path.join(root, file)
|
||||||
|
@ -30,14 +27,14 @@ def stow(pkg, stow_dir):
|
||||||
def get_pkgs():
|
def get_pkgs():
|
||||||
pkgs = []
|
pkgs = []
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
for file in os.listdir(DOTS):
|
||||||
for pkg in sys.argv[1:]:
|
if file == ".git":
|
||||||
if os.path.isdir(os.path.join(DOTS, pkg)):
|
continue
|
||||||
pkgs.append(pkg)
|
|
||||||
else:
|
if os.path.isfile(os.path.join(DOTS, file)):
|
||||||
print(f"The package {pkg} is not a valid package.", file=sys.stderr)
|
continue
|
||||||
else:
|
|
||||||
pkgs = [d for d in os.listdir(DOTS) if not d.startswith(".")]
|
pkgs.append(file)
|
||||||
|
|
||||||
return pkgs
|
return pkgs
|
||||||
|
|
||||||
|
@ -51,6 +48,4 @@ def get_stow_dir(pkg):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
for pkg in get_pkgs():
|
for pkg in get_pkgs():
|
||||||
if pkg in ["docs"]: continue
|
|
||||||
|
|
||||||
stow(pkg, get_stow_dir(pkg))
|
stow(pkg, get_stow_dir(pkg))
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
[push]
|
[push]
|
||||||
autoSetupRemote = true
|
autoSetupRemote = true
|
||||||
|
|
||||||
|
[pull]
|
||||||
|
rebase = true
|
||||||
|
|
||||||
[alias]
|
[alias]
|
||||||
s = status -u
|
s = status -u
|
||||||
a = add -A
|
a = add -A
|
||||||
|
|
1
zsh/.gitignore
vendored
1
zsh/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
zsh-secrets
|
|
Loading…
Reference in a new issue