mirror of
https://github.com/0xacx/chatGPT-shell-cli.git
synced 2024-11-24 11:25:31 +00:00
Formatting. Make tabs consistent to 4 spaces
This commit is contained in:
parent
926587a223
commit
9f4d670064
118
install.sh
118
install.sh
@ -1,39 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
# Check dependencies
|
||||
if type curl &>/dev/null; then
|
||||
echo "" &>/dev/null
|
||||
echo "" &>/dev/null
|
||||
else
|
||||
echo "You need to install 'curl' to use the chatgpt script."
|
||||
exit
|
||||
echo "You need to install 'curl' to use the chatgpt script."
|
||||
exit
|
||||
fi
|
||||
if type jq &>/dev/null; then
|
||||
echo "" &>/dev/null
|
||||
echo "" &>/dev/null
|
||||
else
|
||||
echo "You need to install 'jq' to use the chatgpt script."
|
||||
exit
|
||||
echo "You need to install 'jq' to use the chatgpt script."
|
||||
exit
|
||||
fi
|
||||
|
||||
# Installing imgcat if using iTerm
|
||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
if [[ ! $(which imgcat) ]]; then
|
||||
curl -sS https://iterm2.com/utilities/imgcat -o /usr/local/bin/imgcat
|
||||
chmod +x /usr/local/bin/imgcat
|
||||
echo "Installed imgcat"
|
||||
fi
|
||||
if [[ ! $(which imgcat) ]]; then
|
||||
curl -sS https://iterm2.com/utilities/imgcat -o /usr/local/bin/imgcat
|
||||
chmod +x /usr/local/bin/imgcat
|
||||
echo "Installed imgcat"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Installing magick if using kitty
|
||||
if [[ "$TERM" == "xterm-kitty" ]]; then
|
||||
if [[ ! $(which magick) ]]; then
|
||||
curl -sS https://imagemagick.org/archive/binaries/magick -o /usr/local/bin/magick
|
||||
chmod +x /usr/local/bin/magick
|
||||
echo "Installed magick"
|
||||
fi
|
||||
if [[ ! $(which magick) ]]; then
|
||||
curl -sS https://imagemagick.org/archive/binaries/magick -o /usr/local/bin/magick
|
||||
chmod +x /usr/local/bin/magick
|
||||
echo "Installed magick"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Installing chatgpt script
|
||||
@ -41,7 +41,7 @@ curl -sS https://raw.githubusercontent.com/0xacx/chatGPT-shell-cli/main/chatgpt.
|
||||
|
||||
# Replace open image command with xdg-open for linux systems
|
||||
if [[ "$OSTYPE" == "linux"* ]] || [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||
sed -i 's/open "\${image_url}"/xdg-open "\${image_url}"/g' '/usr/local/bin/chatgpt'
|
||||
sed -i 's/open "\${image_url}"/xdg-open "\${image_url}"/g' '/usr/local/bin/chatgpt'
|
||||
fi
|
||||
chmod +x /usr/local/bin/chatgpt
|
||||
echo "Installed chatgpt script to /usr/local/bin/chatgpt"
|
||||
@ -51,48 +51,48 @@ 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
|
||||
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
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
|
||||
# Adding OpenAI key to shell profile
|
||||
# zsh profile
|
||||
if [ -f ~/.zprofile ]; then
|
||||
echo "export OPENAI_KEY=$key" >>~/.zprofile
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zprofile
|
||||
fi
|
||||
echo "OpenAI key and chatgpt path added to ~/.zprofile"
|
||||
source ~/.zprofile
|
||||
# zshrc profile for debian
|
||||
elif [ -f ~/.zshrc ]; then
|
||||
echo "export OPENAI_KEY=$key" >>~/.zshrc
|
||||
if [[ ":$PATH:" == *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zshrc
|
||||
fi
|
||||
echo "OpenAI key and chatgpt path added to ~/.zshrc"
|
||||
source ~/.zshrc
|
||||
# bash profile mac
|
||||
elif [ -f ~/.bash_profile ]; then
|
||||
echo "export OPENAI_KEY=$key" >>~/.bash_profile
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
|
||||
fi
|
||||
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
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
|
||||
fi
|
||||
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 "OpenAI key and chatgpt path added to ~/.zprofile"
|
||||
source ~/.zprofile
|
||||
# zshrc profile for debian
|
||||
elif [ -f ~/.zshrc ]; then
|
||||
echo "export OPENAI_KEY=$key" >>~/.zshrc
|
||||
if [[ ":$PATH:" == *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.zshrc
|
||||
fi
|
||||
echo "OpenAI key and chatgpt path added to ~/.zshrc"
|
||||
source ~/.zshrc
|
||||
# bash profile mac
|
||||
elif [ -f ~/.bash_profile ]; then
|
||||
echo "export OPENAI_KEY=$key" >>~/.bash_profile
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.bash_profile
|
||||
fi
|
||||
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
|
||||
if [[ ":$PATH:" != *":/usr/local/bin:"* ]]; then
|
||||
echo 'export PATH=$PATH:/usr/local/bin' >>~/.profile
|
||||
fi
|
||||
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"
|
||||
echo "Installation complete"
|
||||
|
||||
else
|
||||
echo "Please take a look at the instructions to install manually: https://github.com/0xacx/chatGPT-shell-cli/tree/main#manual-installation "
|
||||
exit
|
||||
echo "Please take a look at the instructions to install manually: https://github.com/0xacx/chatGPT-shell-cli/tree/main#manual-installation"
|
||||
exit
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user