Skip to content

Commit d46808b

Browse files
committed
Add check to get user consent to edit shell profile during install
1 parent 62208ec commit d46808b

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

install.sh

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,39 @@ fi
3737
chmod +x /usr/local/bin/chatgpt
3838
echo "Installed chatgpt script to /usr/local/bin/chatgpt"
3939

40-
read -p "Please enter your OpenAI API key: " key
40+
echo "The script will add the OPENAI_KEY environment variable to your shell profile and add /usr/local/bin to your PATH"
41+
echo "Would you like to continue? (Yes/No)"
42+
read -e answer
43+
if [ "$answer" == "Yes" ] || [ "$answer" == "yes" ] || [ "$answer" == "y" ] || [ "$answer" == "Y" ] || [ "$answer" == "ok" ]; then
44+
45+
read -p "Please enter your OpenAI API key: " key
46+
47+
# Adding OpenAI key to shell profile
48+
# zsh profile
49+
if [ -f ~/.zprofile ]; then
50+
echo "export OPENAI_KEY=$key" >>~/.zprofile
51+
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
52+
echo "OpenAI key and chatgpt path added to ~/.zprofile"
53+
source ~/.zprofile
54+
# bash profile mac
55+
elif [ -f ~/.bash_profile ]; then
56+
echo "export OPENAI_KEY=$key" >>~/.bash_profile
57+
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
58+
echo "OpenAI key and chatgpt path added to ~/.bash_profile"
59+
source ~/.bash_profile
60+
# profile ubuntu
61+
elif [ -f ~/.profile ]; then
62+
echo "export OPENAI_KEY=$key" >>~/.profile
63+
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
64+
echo "OpenAI key and chatgpt path added to ~/.profile"
65+
source ~/.profile
66+
else
67+
export OPENAI_KEY=$key
68+
echo "You need to add this to your shell profile: export OPENAI_KEY=$key"
69+
fi
70+
echo "Installation complete"
4171

42-
# Adding OpenAI key to shell profile
43-
# zsh profile
44-
if [ -f ~/.zprofile ]; then
45-
echo "export OPENAI_KEY=$key" >>~/.zprofile
46-
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
47-
echo "OpenAI key and chatgpt path added to ~/.zprofile"
48-
source ~/.zprofile
49-
# bash profile mac
50-
elif [ -f ~/.bash_profile ]; then
51-
echo "export OPENAI_KEY=$key" >>~/.bash_profile
52-
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
53-
echo "OpenAI key and chatgpt path added to ~/.bash_profile"
54-
source ~/.bash_profile
55-
# profile ubuntu
56-
elif [ -f ~/.profile ]; then
57-
echo "export OPENAI_KEY=$key" >>~/.profile
58-
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
59-
echo "OpenAI key and chatgpt path added to ~/.profile"
60-
source ~/.profile
6172
else
62-
export OPENAI_KEY=$key
63-
echo "You need to add this to your shell profile: export OPENAI_KEY=$key"
73+
echo "Please take a look at the instructions to install manually: https://github.com/0xacx/chatGPT-shell-cli/tree/main#manual-installation "
74+
exit
6475
fi
65-
echo "Installation complete"

0 commit comments

Comments
 (0)