Comment by cedws 2 months ago Can it be made to be directly executable with a shebang line? 7 comments cedws Reply leobuskin 2 months ago /usr/local/bin/promptrun #!/bin/bash file="$1" model=$(sed -n '2p' "$file" | sed 's/^# \*//') prompt=$(tail -n +3 "$file") curl -s https://api.anthropic.com/v1/messages \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "content-type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d "{ \"model\": \"$model\", \"max_tokens\": 1024, \"messages\": [{\"role\": \"user\", \"content\": $(echo "$prompt" | jq -Rs .)}] }" | jq -r '.content[0].text' hello.prompt #!/usr/local/bin/promptrun # claude-sonnet-4-20250514 Write a haiku about terminal commands. chr15m 2 months ago This is cool. An even more minimal bash version. Love it! _joel 2 months ago it already has one - https://github.com/chr15m/runprompt/blob/main/runprompt#L1If you curl/wget a script, you still need to chmod +x it. Git doesn't have this issue as it retains the file metadata. vidarh 2 months ago I'm assuming the intent was to as if the *.prompt files could have a shebang line. #!/bin/env runprompt --- .frontmatter... --- The prompt. Would be a lot nicer, as then you can just +x the prompt file itself. chr15m 2 months ago I added this and you can now make .prompt files with a runprompt shebang.#/usr/bin/env runprompt chr15m 2 months ago That's on my TODO list for tomorrow, thanks!
leobuskin 2 months ago /usr/local/bin/promptrun #!/bin/bash file="$1" model=$(sed -n '2p' "$file" | sed 's/^# \*//') prompt=$(tail -n +3 "$file") curl -s https://api.anthropic.com/v1/messages \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "content-type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d "{ \"model\": \"$model\", \"max_tokens\": 1024, \"messages\": [{\"role\": \"user\", \"content\": $(echo "$prompt" | jq -Rs .)}] }" | jq -r '.content[0].text' hello.prompt #!/usr/local/bin/promptrun # claude-sonnet-4-20250514 Write a haiku about terminal commands. chr15m 2 months ago This is cool. An even more minimal bash version. Love it!
_joel 2 months ago it already has one - https://github.com/chr15m/runprompt/blob/main/runprompt#L1If you curl/wget a script, you still need to chmod +x it. Git doesn't have this issue as it retains the file metadata. vidarh 2 months ago I'm assuming the intent was to as if the *.prompt files could have a shebang line. #!/bin/env runprompt --- .frontmatter... --- The prompt. Would be a lot nicer, as then you can just +x the prompt file itself.
vidarh 2 months ago I'm assuming the intent was to as if the *.prompt files could have a shebang line. #!/bin/env runprompt --- .frontmatter... --- The prompt. Would be a lot nicer, as then you can just +x the prompt file itself.
chr15m 2 months ago I added this and you can now make .prompt files with a runprompt shebang.#/usr/bin/env runprompt
/usr/local/bin/promptrun
hello.prompt
This is cool. An even more minimal bash version. Love it!
it already has one - https://github.com/chr15m/runprompt/blob/main/runprompt#L1
If you curl/wget a script, you still need to chmod +x it. Git doesn't have this issue as it retains the file metadata.
I'm assuming the intent was to as if the *.prompt files could have a shebang line.
Would be a lot nicer, as then you can just +x the prompt file itself.
I added this and you can now make .prompt files with a runprompt shebang.
#/usr/bin/env runprompt
That's on my TODO list for tomorrow, thanks!