~kris/dots

srice

ref: 2582f0c4173a4ad6a31e0cb759473c893cdc4e93 srice/.local/bin/note-graph -rwxr-xr-x 618 bytes
2582f0c4 — Kris Yotam sb-cpu: portable temp source (Intel Core 0, AMD Tdie/Tctl, Asahi NVMe Composite fallback) 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# note-graph -- generate link graph from [[wikilink]] notes
# Usage: note-graph [notes_dir] [output.dot]
set -euo pipefail
notes_dir="${1:-$HOME/notes}"
output="${2:-/dev/stdout}"

echo "digraph notes {" > "$output"
echo '  rankdir=LR;' >> "$output"
echo '  node [shape=box, style=rounded, fontname="monospace"];' >> "$output"

for f in "$notes_dir"/*.md; do
    [ -f "$f" ] || continue
    src=$(basename "$f" .md)
    grep -oP '\[\[([^\]|]+)' "$f" 2>/dev/null | sed 's/\[\[//' | while read -r target; do
        echo "  \"$src\" -> \"$target\";" >> "$output"
    done
done

echo "}" >> "$output"