fleshed out install script

This commit is contained in:
Josh Ashton
2024-02-12 21:21:59 -07:00
parent 992be20c10
commit 453fc683e5
+124 -13
View File
@@ -3,20 +3,66 @@
# This is the intial install script for quaxlyqueen/scripts.
# It will install the scripts and set up the environment.
# Install the scripts
echo "Installing scripts..."
sudo cp * /usr/local/bin
create_theme() {
USER=$1
su $USER -c "mkdir /home/$USER/.config/theme"
# Set up the environment
echo "Setting up the environment..."
echo "export PATH=$PATH:/usr/local/bin" >> ~/.zshrc
echo "\nTheming currently supports .theme files with 3 colors: base, accent, and hover."
echo "These themes can be changed at anytime by editing the .theme file in ~/.config/theme."
echo "Supported applications will automatically use the active.theme link to theme themselves."
echo "active.theme is a symbolic link to (for eg.) light.theme or dark.theme."
# Install the dependencies
echo "Installing dependencies..."
echo "\nMany themes can be created with this format, and using the `set-theme <theme>` command."
echo "See `set-theme --help` for more information."
# Install github-cli
if ! command -v "gh" &> /dev/null
then
echo "\n\nYou can create a theme now or use the default light and dark themes."
read "?Do you want to create a theme now? (y/n) " CHOICE
USER=$SUDO_USER
DIR="/home/$USER/.config/theme"
if [[ $CHOICE == "y" ]]; then
echo "\n"
read "?Please enter the base color in hex format (e.g. #ffffff): " BASE
read "?Please enter the accent color in hex format (e.g. #ffffff): " ACCENT
read "?Please enter the hover color in hex format (e.g. #ffffff): " HOVER
read "?Please enter the name of the theme: " NAME
su $USER -c "echo 'base=$BASE' > $DIR/$NAME.theme"
su $USER -c "echo 'accent=$ACCENT' >> $DIR/$NAME.theme"
su $USER -c "echo 'hover=$HOVER' >> $DIR/$NAME.theme"
echo "Theme created successfully."
echo "You can now use the `set-theme $NAME` command to use this theme."
echo "Setting the active theme to $NAME.theme..."
su $USER -c "ln -s $DIR/$NAME.theme $DIR/active.theme"
else
echo "Creating default light and dark themes..."
su $USER -c "echo 'base=#C6CAED' > $DIR/light.theme"
su $USER -c "echo 'accent=#4D5382' >> $DIR/light.theme"
su $USER -c "echo 'hover=#262940' >> $DIR/light.theme"
su $USER -c "echo 'base=#262940' > $DIR/dark.theme"
su $USER -c "echo 'accent=#4D5382' >> $DIR/dark.theme"
su $USER -c "echo 'hover=#C6CAED' >> $DIR/dark.theme"
read "?Do you want to set the active theme to the dark theme? (y/n) " CHOICE
if [[ $CHOICE == "y" ]]; then
echo "Setting the active theme to dark.theme..."
su $USER -c "ln -s $DIR/dark.theme $DIR/active.theme"
else
echo "Setting the active theme to light.theme..."
su $USER -c "ln -s $DIR/light.theme $DIR/active.theme"
fi
fi
}
install_gh() {
# Install github-cli
if ! command -v "gh" &> /dev/null
then
echo "gh not found. Installing gh..."
COMMAND="gh"
PACKAGE="github-cli"
@@ -54,7 +100,72 @@ then
else
echo "Homebrew or MacPorts not found. Please install one of them before running this script."
exit 1
fi
fi
fi
fi
}
setup_git() {
# Set up gclone
if [ ! -d "/home/$USER/.config/gclone" ]; then
su $USER -c "mkdir /home/$USER/.config/gclone"
su $USER -c "touch /home/$USER/.config/gclone/gclone.conf"
read "?Please enter your GitHub user name for gclone: " GHUSER
su $USER -c "gclone --set-default $GHUSER"
fi
# If the user has not set up git, do so now
if [ ! -f "/home/$USER/.gitconfig" ]; then
read "?Please enter your name for Git: " NAME
read "?Please enter your email for Git: " EMAIL
su $USER -c "git config --global user.name $NAME"
su $USER -c "git config --global user.email $EMAIL"
fi
# If the user has not set up github-cli, do so now
install_gh
if [ ! -f "/home/$USER/.config/gh/hosts.yml" ]; then
echo "Please log in to GitHub using github-cli."
echo "This will allow you to modify your repositories and other GitHub features."
su $USER -c "gh auth login"
fi
}
# Create environment variables and global aliases
setup_environment() {
echo "Setting up the environment..."
read "?By default, the scripts will install in the /usr/local/bin directory. Is this OK? (y/n): " CHOICE
if [[ $CHOICE == "n" ]]; then
read "?Please enter the directory to install the scripts: " DIR
else
DIR="/usr/local/bin"
fi
echo "# Auto-generated by quaxlyqueen/scripts. Environment setup" >> ~/.zshrc
echo "alias gt='. goto $1'" >> ~/.zshrc
echo "alias goto='. goto $1'" >> ~/.zshrc
echo "export PATH=$PATH:$DIR" >> ~/.zshrc
USER=$SUDO_USER
if [ ! -d "/home/$USER/.config" ]; then
su $USER -c "mkdir /home/$USER/.config"
create_theme $USER
fi
if [ ! -d "/home/$USER/.config/theme" ]; then
create_theme $USER
fi
setup_git
}
# Install the scripts
echo "Installing scripts..."
sudo cp * /usr/local/bin
setup_environment
echo "Installation complete. Please restart your terminal to use the new commands, or run `source ~/.zshrc`."
echo "To remove the scripts, simply delete the files in /usr/local/bin and remove the aliases from your .zshrc file."
echo "Thank you for using quaxlyqueen/scripts!"
exit 0