Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:07:40 +08:00
commit 62bdadcc4f
9 changed files with 1067 additions and 0 deletions

97
commands/notes-capture.md Normal file
View File

@@ -0,0 +1,97 @@
# Quick Note Capture
Quickly capture information into Apple Notes from the command line.
## Instructions
1. **Determine capture type** - Ask what kind of note the user wants to create:
- Quick thought/idea
- Meeting notes
- Code snippet
- Reference information
- Journal entry
2. **Gather content** - Get the note content from the user or from context:
- If they provide content, use it directly
- If capturing from clipboard, help them pipe it in
- If from a file, read and include it
3. **Generate appropriate title** - Based on content type:
- Quick thoughts: `Idea - [brief description]`
- Meeting: `Meeting - [topic] - YYYY-MM-DD`
- Code: `Code - [language/purpose]`
- Reference: `Ref - [topic]`
- Journal: `Journal - YYYY-MM-DD`
4. **Create the note** - Use the notes CLI:
```bash
notes create "Title" << 'EOF'
Content here
EOF
```
5. **Confirm creation** - Verify the note was created:
```bash
notes show "Title"
```
## Quick Capture Templates
### Idea Note
```bash
notes create "Idea - [description]" << 'EOF'
## Idea
[Main idea]
## Context
[Why this came to mind]
## Next Steps
- [ ] Action item
EOF
```
### Meeting Note
```bash
notes create "Meeting - [topic] - $(date +%Y-%m-%d)" << 'EOF'
# [Topic] Meeting
## Attendees
-
## Agenda
1.
## Discussion
## Action Items
- [ ]
## Next Meeting
EOF
```
### Code Snippet
```bash
notes create "Code - [description]" << 'EOF'
## Purpose
[What this code does]
## Code
```[language]
[code here]
```
## Usage
[How to use it]
EOF
```
## Important Notes
- Always quote titles with spaces
- Use heredoc syntax for multi-line content
- Verify note was created successfully
- Suggest reviewing with `notes show` after creation

108
commands/notes-export.md Normal file
View File

@@ -0,0 +1,108 @@
# Export Apple Notes
Export notes to files for backup, sharing, or migration.
## Instructions
1. **Determine export scope**:
- Single note
- Multiple notes by pattern
- All notes
2. **Choose export format**:
- Markdown (.md) - Recommended
- Plain text (.txt)
- Combined single file
- Individual files per note
3. **Set export location**:
- Default: `~/Desktop/notes_export/`
- Or user-specified directory
4. **Execute export**:
- Create export directory
- Export notes with proper naming
- Preserve formatting
5. **Verify and report**:
- Count exported notes
- Report any errors
- Show export location
## Export Commands
### Single Note Export
```bash
mkdir -p ~/Desktop/notes_export
notes show "Note Title" > ~/Desktop/notes_export/note-title.md
```
### Export by Pattern
```bash
mkdir -p ~/Desktop/notes_export
notes list | grep -i "meeting" | while read -r title; do
# Sanitize filename
filename=$(echo "$title" | tr ' ' '-' | tr -cd '[:alnum:]-')
notes show "$title" > ~/Desktop/notes_export/"$filename.md"
echo "Exported: $title"
done
```
### Export All Notes
```bash
mkdir -p ~/Desktop/notes_export
export_date=$(date +%Y-%m-%d)
notes list | while read -r title; do
# Create safe filename
filename=$(echo "$title" | tr ' /' '-' | tr -cd '[:alnum:]-')
notes show "$title" > ~/Desktop/notes_export/"$filename.md"
done
echo "Export complete: ~/Desktop/notes_export"
ls -la ~/Desktop/notes_export | head -20
```
### Combined Export (Single File)
```bash
output_file=~/Desktop/all_notes_$(date +%Y-%m-%d).md
echo "# Apple Notes Export - $(date +%Y-%m-%d)" > "$output_file"
echo "" >> "$output_file"
notes list | while read -r title; do
echo "## $title" >> "$output_file"
echo "" >> "$output_file"
notes show "$title" >> "$output_file"
echo "" >> "$output_file"
echo "---" >> "$output_file"
echo "" >> "$output_file"
done
echo "Exported to: $output_file"
```
### Export with Index
```bash
mkdir -p ~/Desktop/notes_export
index_file=~/Desktop/notes_export/INDEX.md
echo "# Notes Export Index" > "$index_file"
echo "Exported: $(date)" >> "$index_file"
echo "" >> "$index_file"
notes list | while read -r title; do
filename=$(echo "$title" | tr ' /' '-' | tr -cd '[:alnum:]-')
notes show "$title" > ~/Desktop/notes_export/"$filename.md"
echo "- [$title](./$filename.md)" >> "$index_file"
done
```
## Important Notes
- Sanitize filenames to remove special characters
- Consider note content length for combined exports
- Backup existing export directories before overwriting
- Use UTF-8 encoding for proper character support
- Add export date to directory or filename for versioning

95
commands/notes-search.md Normal file
View File

@@ -0,0 +1,95 @@
# Search Apple Notes
Find notes by title patterns or content keywords.
## Instructions
1. **Get search query** - Ask what the user is looking for:
- Specific note title
- Topic or keyword
- Date range
- Category or tag
2. **Search by title** - First search note titles:
```bash
notes list | grep -i "[query]"
```
3. **Search by content** - If title search insufficient, search note contents:
```bash
# 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
```
4. **Display results** - Show matching notes with context:
- List matching note titles
- Optionally show preview of content
- Highlight the matching terms
5. **Offer next actions**:
- View full content of a specific note
- Narrow search with additional terms
- Export results
## Search Patterns
### Case-insensitive title search
```bash
notes list | grep -i "keyword"
```
### Multiple keywords (AND)
```bash
notes list | grep -i "keyword1" | grep -i "keyword2"
```
### Date-based search
```bash
# Notes from January 2024
notes list | grep "2024-01"
# Notes from this year
notes list | grep "$(date +%Y)"
```
### Pattern matching
```bash
# 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:
```bash
#!/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