~kris/dots

srice

ref: 178c9a25a484ead715392d50e21d03df486b8b41 srice/.local/bin/note-graph -rwxr-xr-x 618 bytes
178c9a25 — Kris Yotam conky: sync proper config from moirai (was the greenred variant) 2 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"