reorg: move tpl/bin under 000-configs, files->assets, add bump-version.sh + plugins doc

This commit is contained in:
stateofshit
2026-07-29 15:07:36 +00:00
parent 0733aef8c0
commit 35c69bc1eb
15 changed files with 158 additions and 16 deletions
View File
+23
View File
@@ -0,0 +1,23 @@
---
title: "bin"
status: "active"
folder: "bin"
tags: [scripts, index]
created: "2026-07-29"
updated: "2026-07-29"
version: "1.0.0"
---
# bin
Helper shell scripts.
## Current
- [[daily.sh]] — auto-create today's daily note from `tpl/daily.md`. Run from cron on the main server, not from openwebui.
## Adding a script
- Filename: `snake_case.sh`
- Must be executable (`chmod +x`)
- Add to this README
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# bin/bump-version.sh — auto-increment version in YAML frontmatter
# Usage:
# bin/bump-version.sh <file> # bump patch (default)
# bin/bump-version.sh <file> --patch # bump patch
# bin/bump-version.sh <file> --minor # bump minor, reset patch
# bin/bump-version.sh <file> --major # bump major, reset minor+patch
#
# Reads YAML frontmatter, increments version, updates `updated` field.
# Writes back in-place.
set -e
FILE="$1"
BUMP="${2:---patch}"
if [ -z "$FILE" ]; then
echo "Usage: $0 <file> [--patch|--minor|--major]" >&2
exit 1
fi
if [ ! -f "$FILE" ]; then
echo "File not found: $FILE" >&2
exit 1
fi
# Extract version
CURRENT=$(head -20 "$FILE" | grep -E '^version:' | head -1 | sed 's/version: *//; s/"//g')
if [ -z "$CURRENT" ]; then
echo "No version field in frontmatter" >&2
exit 1
fi
# Parse semver
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "$BUMP" in
--major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
--minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
--patch|*)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
TODAY=$(date +%Y-%m-%d)
# Replace in file (in-place)
sed -i.bak \
-e "s|^version:.*|version: \"$NEW_VERSION\"|" \
-e "s|^updated:.*|updated: \"$TODAY\"|" \
"$FILE"
rm -f "$FILE.bak"
echo "$FILE: $CURRENT -> $NEW_VERSION (updated: $TODAY)"
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
# bin/daily.sh — auto-create today's daily note from template
# Cron: 0 6 * * * /home/user/02-repos/shit_in_a_vault/bin/daily.sh
VAULT="/home/user/02-repos/shit_in_a_vault"
TPL="$VAULT/tpl/daily.md"
DEST_DIR="$VAULT/01-logs/daily"
DEST="$DEST_DIR/$(date +%Y-%m-%d).md"
DATE_STR=$(date +%Y-%m-%d)
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
mkdir -p "$DEST_DIR"
if [ -f "$DEST" ]; then
echo "Daily note $DEST already exists, skipping."
exit 0
fi
if [ ! -f "$TPL" ]; then
echo "Template not found: $TPL" >&2
exit 1
fi
# Substitute {{date:YYYY-MM-DD}} and {{date:}} placeholders
sed -e "s|{{date:YYYY-MM-DD}}|$DATE_STR|g" \
-e "s|{{date:}}|$DATE_STR|g" \
-e "s|{{yesterday:YYYY-MM-DD}}|$YESTERDAY|g" \
"$TPL" > "$DEST"
echo "Created: $DEST"
# Commit and push
cd "$VAULT" || exit 1
git add "$DEST"
if git diff --cached --quiet; then
echo "Nothing to commit."
exit 0
fi
git commit -m "daily: $DATE_STR" && git push