2.0 KiB
2.0 KiB
Search Apple Notes
Find notes by title patterns or content keywords.
Instructions
-
Get search query - Ask what the user is looking for:
- Specific note title
- Topic or keyword
- Date range
- Category or tag
-
Search by title - First search note titles:
notes list | grep -i "[query]" -
Search by content - If title search insufficient, search note contents:
# Get all notes and search each one for title in $(notes list); do content=$(notes show "$title" 2>/dev/null) if echo "$content" | grep -qi "[query]"; then echo "Found in: $title" fi done -
Display results - Show matching notes with context:
- List matching note titles
- Optionally show preview of content
- Highlight the matching terms
-
Offer next actions:
- View full content of a specific note
- Narrow search with additional terms
- Export results
Search Patterns
Case-insensitive title search
notes list | grep -i "keyword"
Multiple keywords (AND)
notes list | grep -i "keyword1" | grep -i "keyword2"
Date-based search
# Notes from January 2024
notes list | grep "2024-01"
# Notes from this year
notes list | grep "$(date +%Y)"
Pattern matching
# Notes starting with "Meeting"
notes list | grep "^Meeting"
# Notes containing a project name
notes list | grep -i "\[ProjectName\]"
Full-text Search Script
For comprehensive content search:
#!/bin/bash
query="$1"
echo "Searching for: $query"
echo "========================"
notes list | while read -r title; do
content=$(notes show "$title" 2>/dev/null)
if echo "$content" | grep -qi "$query"; then
echo ""
echo "📝 $title"
echo "---"
echo "$content" | grep -i "$query" | head -3
fi
done
Important Notes
- Title search is fast; content search examines each note
- Use specific keywords for better results
- Regex patterns are supported in grep
- Consider case sensitivity when searching