Skip to content

Commit

Permalink
[scripts] ayo: only ask for content in case of command
Browse files Browse the repository at this point in the history
  • Loading branch information
meain committed Aug 11, 2024
1 parent 78dda94 commit d0221f4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions scripts/.local/bin/random/ayo
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ set -e

chatgpt --clear-history >/dev/null

# get the input text from stdin else ask for input
if [ -p /dev/stdin ]; then
input=$(cat)
else
printf "Content: " >&2
read -r input
fi

if [ -n "$2" ]; then
chatgpt "$*"
else
# get the input text from stdin else ask for input
if [ -p /dev/stdin ]; then
input=$(cat)
else
printf "Content: " >&2
read -r input
fi

echo "$input" |
case "$1" in
"professional")
Expand All @@ -26,5 +26,17 @@ else
"email")
chatgpt "Make this into a casual business email."
;;
"summarize")
chatgpt "Can you summarize this message?"
;;
"summary")
chatgpt "Can you summarize this message?"
;;
"keypoints")
chatgpt "List the key points of this message."
;;
*)
chatgpt "$1"
;;
esac
fi

0 comments on commit d0221f4

Please sign in to comment.