25 lines
517 B
Bash
Executable File
25 lines
517 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# description: Search memories by keyword, tag, or title
|
|
# Args: <query>
|
|
|
|
[ -z "$*" ] && echo "usage: memory_recall <query>" && exit 1
|
|
|
|
mount="${OLLIE:-$HOME/mnt/ollie}"
|
|
mem_dir="$mount/m"
|
|
|
|
query="$*"
|
|
|
|
# Search filenames (title/tag match) and file bodies
|
|
matches=$(grep -ril "$query" "$mem_dir" 2>/dev/null)
|
|
|
|
if [ -z "$matches" ]; then
|
|
echo "no matches for: $query"
|
|
exit 0
|
|
fi
|
|
|
|
while IFS= read -r file; do
|
|
echo "=== $(basename "$file") ==="
|
|
cat "$file"
|
|
echo
|
|
done <<< "$matches"
|