-
-
Save maurelian/e8fe11cbdcc8286cab3cb5999c069355 to your computer and use it in GitHub Desktop.
Use this command to get suggestions on how to do things on the command line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TOKEN=< OpenAI token from https://platform.openai.com/account/api-keys > | |
PROMPT="You are the best at writing shell commands. Assume the OS is Ubuntu. I want you to respond with only the shell commands separated by semicolons and no commentary. Here is what I want to do: $@" | |
RESULT=`curl -s https://api.openai.com/v1/chat/completions \ | |
-H 'Content-Type: application/json' \ | |
-H "Authorization: Bearer $TOKEN" \ | |
-d "{ | |
\"model\": \"gpt-3.5-turbo\", | |
\"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}] | |
}" | jq '.choices[] | .message.content' -r` | |
echo $RESULT | |
read -rp "Execute? [y/n/c(opy)]: " input_var | |
input_var=${input_var:-y} | |
[ "$input_var" = "y" ] && bash -c "$RESULT" | |
[ "$input_var" = "c" ] && echo "$RESULT" | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment