Created
April 18, 2023 20:51
-
-
Save hookdump/46cd8bc5eba77552657b634983080c5a to your computer and use it in GitHub Desktop.
Ask ChatGPT in ZSH
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
# Paste your OpenAI API Key here | |
export OPENAI_API_KEY="sk-..." | |
# Display colors | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
# GPT function | |
function gpt { | |
set +o nomatch # disable nomatch option | |
nvm use gpt --silent # node should be >= 18.13.0, you can use an alias for that version | |
local input="$*" # concat args into single string | |
echo -e "${RED}Prompt:${NC} $input" | |
echo -e "${RED}ChatGPT:${NC}" | |
chatgpt "$input" # call chatgpt cli | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment