Skip to content

Instantly share code, notes, and snippets.

@reagle
Last active January 16, 2024 05:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save reagle/e6da63b553662bd1554dabc5ed6661b8 to your computer and use it in GitHub Desktop.
Save reagle/e6da63b553662bd1554dabc5ed6661b8 to your computer and use it in GitHub Desktop.
Create symbolic links from source Obsidian vault config to target vaults.
#!/usr/bin/env python3
"""Create symbolic links from main Obsidian vault config to other vaults.
Obsidian configuration folder can be copied between vaults; this script
copies a configuration from a main vault to other vaults.
"""
from pathlib import Path
from shutil import copytree, rmtree
main = Path("~/data/2web/reagle.org/joseph/plan/ob-plan/.obsidian").expanduser()
others = [
Path(t).expanduser()
for t in [
"~/data/2misc/ob-misc/.obsidian",
"~/data/2web/reagle.org/joseph/ob-codex/.obsidian",
"~/data/mom/ob-mom/.obsidian",
]
]
print(f"{main=}")
for other in others:
print(f"checking {other=}")
if other.exists():
if other.is_symlink():
other.unlink()
print(f" unlinked {other=}")
elif other.is_dir():
rmtree(other)
print(f" removed {other=}")
else:
raise TypeError(f" unknown type: {other}")
else:
print(f" doesn't exist yet {other=}")
copytree(main, other)
print(f" copied to {other=}")
@DearVikki
Copy link

Thanks ☕️, super handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment