Add check to get user consent to edit shell profile during install

This commit is contained in:
Achilleas 2023-03-20 18:29:49 +02:00
parent 62208ecb5b
commit d46808bec9

View File

@ -37,29 +37,39 @@ fi
chmod +x /usr/local/bin/chatgpt
echo "Installed chatgpt script to /usr/local/bin/chatgpt"
read -p "Please enter your OpenAI API key: " key
echo "The script will add the OPENAI_KEY environment variable to your shell profile and add /usr/local/bin to your PATH"
echo "Would you like to continue? (Yes/No)"
read -e answer
if [ "$answer" == "Yes" ] || [ "$answer" == "yes" ] || [ "$answer" == "y" ] || [ "$answer" == "Y" ] || [ "$answer" == "ok" ]; then
read -p "Please enter your OpenAI API key: " key
# Adding OpenAI key to shell profile
# zsh profile
if [ -f ~/.zprofile ]; then
echo "export OPENAI_KEY=$key" >>~/.zprofile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
echo "OpenAI key and chatgpt path added to ~/.zprofile"
source ~/.zprofile
# bash profile mac
elif [ -f ~/.bash_profile ]; then
echo "export OPENAI_KEY=$key" >>~/.bash_profile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
echo "OpenAI key and chatgpt path added to ~/.bash_profile"
source ~/.bash_profile
# profile ubuntu
elif [ -f ~/.profile ]; then
echo "export OPENAI_KEY=$key" >>~/.profile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
echo "OpenAI key and chatgpt path added to ~/.profile"
source ~/.profile
else
export OPENAI_KEY=$key
echo "You need to add this to your shell profile: export OPENAI_KEY=$key"
fi
echo "Installation complete"
# Adding OpenAI key to shell profile
# zsh profile
if [ -f ~/.zprofile ]; then
echo "export OPENAI_KEY=$key" >>~/.zprofile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
echo "OpenAI key and chatgpt path added to ~/.zprofile"
source ~/.zprofile
# bash profile mac
elif [ -f ~/.bash_profile ]; then
echo "export OPENAI_KEY=$key" >>~/.bash_profile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
echo "OpenAI key and chatgpt path added to ~/.bash_profile"
source ~/.bash_profile
# profile ubuntu
elif [ -f ~/.profile ]; then
echo "export OPENAI_KEY=$key" >>~/.profile
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
echo "OpenAI key and chatgpt path added to ~/.profile"
source ~/.profile
else
export OPENAI_KEY=$key
echo "You need to add this to your shell profile: export OPENAI_KEY=$key"
echo "Please take a look at the instructions to install manually: https://github.com/0xacx/chatGPT-shell-cli/tree/main#manual-installation "
exit
fi
echo "Installation complete"