logoalt Hacker News

dakinitribelast Sunday at 7:22 AM1 replyview on HN

This is beautiful, thank you.

Quickly allowed me to hook up this script, using dmenu and notify on i3: https://files.catbox.moe/vbhtg0.jpg

And then trigger it with Mod+l for super quick answers as I'm working! Priceless <3


Replies

HiPHInchlast Sunday at 7:37 AM

ported to macos using raycast

```

#!/bin/bash

# Required parameters: # @raycast.schemaVersion 1 # @raycast.title Ask LLM # @raycast.mode fullOutput

# Optional parameters: # @raycast.icon # @raycast.argument1 { "type": "text", "placeholder": "Your question" }

# Documentation: # @raycast.author Your Name # @raycast.authorURL https://github.com/you

QUERY="$1" [ -z "$QUERY" ] && exit 0

FULL_QUERY="Answer in as little words as possible, concisely, for an intelligent person: $QUERY"

# URL encode (pure bash) encode_query() { local query="$1" local encoded="" local c for (( i=0; i<${#query}; i++ )); do c="${query:$i:1}" case $c in [a-zA-Z0-9.~_-]) encoded+="$c" ;; *) encoded+=$(printf '%%%02X' "'$c") ;; esac done echo "$encoded" }

ENCODED_QUERY=$(encode_query "$FULL_QUERY")

# Get response RESPONSE=$(curl -s "https://ch.at/?q=$ENCODED_QUERY")

# Output to Raycast echo "$RESPONSE"

# --- Optional: also pop up a big dialog --- osascript -e 'display dialog "'"$RESPONSE"'" buttons {"OK"} default button 1 with title "LLM Answer"'

```