Adds a 6-phase skill that scaffolds the PKM system onto existing Obsidian
vaults: scan structure, map folders, personalize, generate config, scaffold
missing pieces, and verify. Replaces hardcoded folder paths in hooks with
env var lookups (${VAR:-Default}) so adopted vaults with custom folder names
work correctly while template-based vaults remain unaffected.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Auto-commit hook for vault changes
|
|
# Called after Write/Edit operations on vault files
|
|
|
|
VAULT_PATH="${VAULT_PATH:-$(pwd)}"
|
|
MODIFIED_FILE="${1:-unknown}"
|
|
|
|
# Only run if auto-commit is enabled
|
|
if [ "${GIT_AUTO_COMMIT}" != "true" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
cd "$VAULT_PATH" || exit 0
|
|
|
|
# Check if this is a git repository
|
|
if [ ! -d .git ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Check if there are changes to commit
|
|
if git diff --quiet && git diff --staged --quiet; then
|
|
exit 0
|
|
fi
|
|
|
|
# Generate commit message based on file location
|
|
TIMESTAMP=$(date +"%Y-%m-%d %H:%M")
|
|
|
|
DAILY_DIR="${DAILY_NOTES_DIR:-Daily Notes}"
|
|
GOALS_DIR_NAME="${GOALS_DIR:-Goals}"
|
|
PROJECTS_DIR_NAME="${PROJECTS_DIR:-Projects}"
|
|
TEMPLATES_DIR_NAME="${TEMPLATES_DIR:-Templates}"
|
|
|
|
if [[ "$MODIFIED_FILE" == *"$DAILY_DIR"* ]]; then
|
|
MSG="Update daily note - $TIMESTAMP"
|
|
elif [[ "$MODIFIED_FILE" == *"$GOALS_DIR_NAME"* ]]; then
|
|
MSG="Update goals - $TIMESTAMP"
|
|
elif [[ "$MODIFIED_FILE" == *"$PROJECTS_DIR_NAME"* ]]; then
|
|
PROJECT=$(echo "$MODIFIED_FILE" | sed "s|.*/$PROJECTS_DIR_NAME/\([^/]*\)/.*|\1|")
|
|
MSG="Update project: $PROJECT - $TIMESTAMP"
|
|
elif [[ "$MODIFIED_FILE" == *"$TEMPLATES_DIR_NAME"* ]]; then
|
|
MSG="Update template - $TIMESTAMP"
|
|
else
|
|
MSG="Vault update - $TIMESTAMP"
|
|
fi
|
|
|
|
# Stage and commit
|
|
git add .
|
|
git commit -m "$MSG" --quiet 2>/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "Auto-committed: $MSG"
|
|
fi
|