27 lines
669 B
Bash
Executable File
27 lines
669 B
Bash
Executable File
#!/bin/bash
|
|
# AskFile - Ask ollie about the current file in acme
|
|
#
|
|
# Usage: Middle-click AskFile in the tag
|
|
# Sends: "Describe and explain this file: <filename>"
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ -z "${winid:-}" ]]; then
|
|
echo "AskFile must be run from within acme" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Get the window name (filename) from the tag
|
|
filename=$(9p read acme/$winid/tag | awk '{print $1}')
|
|
|
|
if [[ -z "$filename" || "$filename" == *"+Errors" || "$filename" == "+*" ]]; then
|
|
echo "No file associated with this window" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Build the prompt
|
|
prompt="Describe and explain this file: $filename"
|
|
|
|
# Send to ollie via one-shot generation
|
|
echo "$prompt" | o generate
|