cleanup & organization. added .gitignore -> .env to ginit
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -1,113 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
error() {
|
|
||||||
echo "Your package manager is not supported."
|
|
||||||
echo "$COMMAND could not be installed automatically."
|
|
||||||
echo "Please install $COMMAND manually before running this script."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
install() {
|
|
||||||
COMMAND=$1
|
|
||||||
PACKAGE=$2
|
|
||||||
|
|
||||||
if ! command -v $COMMAND &> /dev/null
|
|
||||||
then
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
||||||
echo "$COMMAND not found. Installing $PACKAGE..."
|
|
||||||
|
|
||||||
DISTRO=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"')
|
|
||||||
|
|
||||||
if [[ $DISTRO == "arch" ]]; then
|
|
||||||
yes | sudo pacman -S $PACKAGE
|
|
||||||
yes | sudo pacman -S $COMMAND
|
|
||||||
exit 0
|
|
||||||
elif [[ $DISTRO == "archarm" ]]; then
|
|
||||||
yes | sudo pacman -S $PACKAGE
|
|
||||||
yes | sudo pacman -S $COMMAND
|
|
||||||
exit 0
|
|
||||||
elif [[ $DISTRO == "ubuntu" ]]; then
|
|
||||||
yes | sudo apt-get install $PACKAGE
|
|
||||||
yes | sudo apt-get install $COMMAND
|
|
||||||
exit 0
|
|
||||||
elif [[ $DISTRO == "fedora" ]]; then
|
|
||||||
yes | sudo dnf install $PACKAGE
|
|
||||||
yes | sudo dnf install $COMMAND
|
|
||||||
exit 0
|
|
||||||
elif [[ $DISTRO == "centos" ]]; then
|
|
||||||
yes | sudo yum install $PACKAGE
|
|
||||||
yes | sudo yum install $COMMAND
|
|
||||||
exit 0
|
|
||||||
elif [[ $DISTRO == "debian" ]]; then
|
|
||||||
yes | sudo apt install $PACKAGE
|
|
||||||
yes | sudo apt install $COMMAND
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
error
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
echo "$COMMAND not found. Installing $PACKAGE..."
|
|
||||||
|
|
||||||
if command -v "brew" &> /dev/null
|
|
||||||
then
|
|
||||||
yes | brew install $PACKAGE
|
|
||||||
yes | brew install $COMMAND
|
|
||||||
|
|
||||||
elif command -v "port" &> /dev/null
|
|
||||||
then
|
|
||||||
yes | sudo port install $PACKAGE
|
|
||||||
yes | sudo port install $COMMAND
|
|
||||||
else
|
|
||||||
echo "Homebrew or MacPorts not found. Please install one of them before running this script."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
error
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Package $PACKAGE is already installed."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# If the number of arguments is not 2, print the usage
|
|
||||||
if [[ $# -ne 2 ]]; then
|
|
||||||
echo "Usage: check-dependency <command> <package>"
|
|
||||||
echo " check-dependency <--git> <user/repo>"
|
|
||||||
echo "Checks if a command is installed and if not, installs the package."
|
|
||||||
echo "If --git is specified, it will check if the git repository is executable."
|
|
||||||
echo "Supported package managers: apt, pacman, dnf, yum, brew, port"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
COMMAND=$1
|
|
||||||
PACKAGE=$2
|
|
||||||
|
|
||||||
# If the command is git, we will clone the repository and install it
|
|
||||||
if [[ "$COMMAND" == "--git" ]]; then
|
|
||||||
USER=$(echo $PACKAGE | cut -d'/' -f1)
|
|
||||||
REPO=$(echo $PACKAGE | cut -d'/' -f2)
|
|
||||||
|
|
||||||
# If the repository is not installed, we will clone it and install it
|
|
||||||
if ! command -v $REPO &> /dev/null
|
|
||||||
then
|
|
||||||
THIS_USER=$SUDO_USER
|
|
||||||
|
|
||||||
if [ ! -d /home/$THIS_USER/build ]; then
|
|
||||||
echo "Creating build directory for user $THIS_USER..."
|
|
||||||
su $THIS_USER -c "mkdir /home/$THIS_USER/build"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd /home/$THIS_USER/build
|
|
||||||
git clone https://github.com/$USER/$REPO
|
|
||||||
cd $REPO
|
|
||||||
inst
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Repository $PACKAGE is already installed."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
install $COMMAND $PACKAGE
|
|
||||||
fi
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
git init
|
git init
|
||||||
|
touch .gitignore
|
||||||
|
echo "*.env" >> .gitignore
|
||||||
|
|
||||||
git stage -A
|
git stage -A
|
||||||
git commit -m "init commit"
|
git commit -m "init commit"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# Dependencies:
|
# Dependencies:
|
||||||
# quaxlyqueen/scripts/mark
|
# quaxlyqueen/scripts/mark
|
||||||
|
|
||||||
BOOKMARKS_FILE="/home/violet/.bookmarks"
|
BOOKMARKS_FILE="/data/data/com.termux/files/home/.bookmarks"
|
||||||
|
|
||||||
# Catch any invalid input.
|
# Catch any invalid input.
|
||||||
if [[ $# -eq 0 || $# -gt 1 ]]; then
|
if [[ $# -eq 0 || $# -gt 1 ]]; then
|
||||||
|
|||||||
@@ -1,278 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
name_executable() {
|
|
||||||
read "?The current name of the executable is $1. Do you want to change it? (y/N)" CHOICE
|
|
||||||
|
|
||||||
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
|
||||||
read "?Enter the name of the executable: " NAME
|
|
||||||
echo $NAME
|
|
||||||
else
|
|
||||||
echo $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
save_desktop_entry() {
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|
||||||
NAME=$1
|
|
||||||
EXECUTABLE=$2
|
|
||||||
|
|
||||||
echo "Creating a desktop entry for the $NAME project...\n"
|
|
||||||
|
|
||||||
# Create the desktop entry
|
|
||||||
sudo echo "[Desktop Entry]" > /usr/share/applications/$NAME.desktop
|
|
||||||
sudo echo "Name=$NAME" >> /usr/share/applications/$NAME.desktop
|
|
||||||
sudo echo "Exec=$EXECUTABLE" >> /usr/share/applications/$NAME.desktop
|
|
||||||
sudo echo "Type=Application" >> /usr/share/applications/$NAME.desktop
|
|
||||||
sudo echo "# Auto-generated by the install script" >> /usr/share/applications/$NAME.desktop
|
|
||||||
else
|
|
||||||
echo "This operating system is not yet supported."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
help() {
|
|
||||||
echo "This script installs a project onto the user's system."
|
|
||||||
echo "Usage: install"
|
|
||||||
echo " install <path-to-project>"
|
|
||||||
echo " install -h | --help"
|
|
||||||
echo "\nIf no path is provided, the script will look for a dependencies.txt file in the current directory."
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
error_missing_dependencies() {
|
|
||||||
echo "The dependencies.txt file is missing from the project directory."
|
|
||||||
echo "This file should contain the required packages for the project to run."
|
|
||||||
echo "The format should be as follows: <command>,<package>"
|
|
||||||
echo "For example: python,python3"
|
|
||||||
echo "Please create this file before continuing."
|
|
||||||
echo "You can find an example file in the root directory of this project."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
success() {
|
|
||||||
NAME=$1
|
|
||||||
EXECUTABLE=$2
|
|
||||||
|
|
||||||
echo "The $NAME project and it's dependencies have been successfully installed onto your system."
|
|
||||||
echo "You can now run the project by typing $EXECUTABLE into the terminal."
|
|
||||||
|
|
||||||
read "?Would you like to create a desktop entry for the $NAME project? (y/N): " CHOICE
|
|
||||||
|
|
||||||
if [[ $CHOICE == "y" || $CHOICE == "Y" ]]; then
|
|
||||||
save_desktop_entry $NAME $EXECUTABLE
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install_c() {
|
|
||||||
NAME=$1
|
|
||||||
echo "\nOther languages and build systems are not yet supported."
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
install_python() {
|
|
||||||
NAME=$1
|
|
||||||
EXECUTABLE=$(name_executable $1)
|
|
||||||
|
|
||||||
# Get the current working directory and the virtual environment
|
|
||||||
CWD=$(pwd)
|
|
||||||
ENV=$(pwd)/bin/activate
|
|
||||||
COMMAND="python $CWD/src/$NAME.py"
|
|
||||||
|
|
||||||
# Create the virtual environment
|
|
||||||
python -m venv .
|
|
||||||
source bin/activate
|
|
||||||
|
|
||||||
# Install Python packages in the virtual environment
|
|
||||||
if [[ -f requirements.txt ]]; then
|
|
||||||
pip install -r requirements.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Create the executable
|
|
||||||
sudo echo "#!/bin/zsh" > /usr/local/bin/$EXECUTABLE
|
|
||||||
sudo echo "source $ENV" >> /usr/local/bin/$EXECUTABLE
|
|
||||||
sudo echo "$COMMAND" >> /usr/local/bin/$EXECUTABLE
|
|
||||||
sudo echo "# Auto-generated by the install script" >> /usr/local/bin/$EXECUTABLE
|
|
||||||
sudo chmod +x /usr/local/bin/$EXECUTABLE
|
|
||||||
|
|
||||||
success "$NAME" "$EXECUTABLE"
|
|
||||||
}
|
|
||||||
|
|
||||||
install_java() {
|
|
||||||
NAME=$1
|
|
||||||
echo "Other languages and build systems are not yet supported."
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
install_other() {
|
|
||||||
NAME=$1
|
|
||||||
echo "Other languages and build systems are not yet supported."
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
install() {
|
|
||||||
PROJECT_NAME=$1
|
|
||||||
|
|
||||||
echo "\nInstalling the $PROJECT_NAME project onto your system..."
|
|
||||||
|
|
||||||
echo "Please select the project language or build system:"
|
|
||||||
echo "1. C"
|
|
||||||
echo "2. Python"
|
|
||||||
echo "3. Java"
|
|
||||||
echo "4. Other"
|
|
||||||
|
|
||||||
read "?Enter the number of the project type: " PROJECT_TYPE
|
|
||||||
|
|
||||||
case $PROJECT_TYPE in
|
|
||||||
1)
|
|
||||||
install_c "$PROJECT_NAME"
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
install_python "$PROJECT_NAME"
|
|
||||||
;;
|
|
||||||
3)
|
|
||||||
install_java "$PROJECT_NAME"
|
|
||||||
;;
|
|
||||||
4)
|
|
||||||
install_other "$PROJECT_NAME"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid option"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
install_dependencies() {
|
|
||||||
echo "Checking for required packages..."
|
|
||||||
|
|
||||||
# Check if the check-dependency command is installed
|
|
||||||
if ! command -v check-dependency &> /dev/null
|
|
||||||
then
|
|
||||||
echo "The command check-dependency could not be found. Please install it before continuing."
|
|
||||||
echo "You can find it at https://github.com/quaxlyqueen/scripts."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Iterate through each line of the dependencies.txt file
|
|
||||||
# and check if the package is installed with check-dependency <command> <package>
|
|
||||||
while read -r line; do
|
|
||||||
command=$(echo $line | awk -F ',' '{print $1}')
|
|
||||||
package=$(echo $line | awk -F ',' '{print $2}')
|
|
||||||
|
|
||||||
check-dependency $command $package
|
|
||||||
|
|
||||||
# If the package could not be installed, exit the script
|
|
||||||
if [[ $? -eq 1 ]]; then
|
|
||||||
echo "The command $command from package $package could not be installed. Please install it manually before continuing."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
done < dependencies.txt
|
|
||||||
}
|
|
||||||
|
|
||||||
check_sudo() {
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
echo "This script must be run as root"
|
|
||||||
echo "Try 'sudo ./install'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_theme() {
|
|
||||||
USER=$SUDO_USER
|
|
||||||
if [ ! -d /home/$USER/.config ];
|
|
||||||
then
|
|
||||||
echo "Creating the ~/.config directory..."
|
|
||||||
su $USER -c "mkdir /home/$USER/.config"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /home/$USER/.config/theme ];
|
|
||||||
then
|
|
||||||
echo "Creating the /home/$USER/.config/theme directory..."
|
|
||||||
su $USER -c "mkdir /home/$USER/.config/theme"
|
|
||||||
fi
|
|
||||||
|
|
||||||
THEME_DIR=/home/$USER/.config/theme
|
|
||||||
|
|
||||||
if [ ! -f $THEME_DIR/active.theme ];
|
|
||||||
then
|
|
||||||
su $USER -c "touch $THEME_DIR/light.theme"
|
|
||||||
echo "base=#C6CAED" > $THEME_DIR/light.theme
|
|
||||||
echo "accent=#4D5382" >> $THEME_DIR/light.theme
|
|
||||||
echo "hover=#262940" >> $THEME_DIR/light.theme
|
|
||||||
|
|
||||||
su $USER -c "touch $THEME_DIR/dark.theme"
|
|
||||||
echo "base=#262940" > $THEME_DIR/dark.theme
|
|
||||||
echo "accent=#4D5382" >> $THEME_DIR/dark.theme
|
|
||||||
echo "hover=#C6CAED" >> $THEME_DIR/dark.theme
|
|
||||||
|
|
||||||
su $USER -c "ln -s $THEME_DIR/dark.theme $THEME_DIR/active.theme"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install-extra() {
|
|
||||||
if [ -f "install-extra" ]; then
|
|
||||||
echo "Running install-extra..."
|
|
||||||
./install-extra
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_args() {
|
|
||||||
check_sudo
|
|
||||||
check_theme
|
|
||||||
|
|
||||||
if [[ $# -gt 1 ]]; then
|
|
||||||
echo "ERROR: There were too many arguments.\n"
|
|
||||||
echo "Usage: install"
|
|
||||||
echo " install <path-to-project>"
|
|
||||||
echo " install -h | --help"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
# No arguments provided
|
|
||||||
elif [[ $# -eq 0 ]]; then
|
|
||||||
|
|
||||||
# Check if the current directory contains the required dependencies.txt file.
|
|
||||||
if [[ ! -f dependencies.txt ]]; then
|
|
||||||
error_missing_dependencies
|
|
||||||
|
|
||||||
# Install the project
|
|
||||||
else
|
|
||||||
PROJECT_NAME=$(pwd | cut -d '/' -f5)
|
|
||||||
install_dependencies
|
|
||||||
install "$PROJECT_NAME"
|
|
||||||
install-extra
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# User argument provided
|
|
||||||
else
|
|
||||||
|
|
||||||
# Display help message
|
|
||||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
|
||||||
help
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the specified directory exists
|
|
||||||
if [[ ! -d $1 ]]; then
|
|
||||||
echo "The specified project directory does not exist"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
# Check if the specified directory contains the required dependencies.txt file.
|
|
||||||
elif [[ ! -f $1/dependencies.txt ]]; then
|
|
||||||
error_missing_dependencies
|
|
||||||
|
|
||||||
# Install the project
|
|
||||||
else
|
|
||||||
PROJECT_NAME=$1
|
|
||||||
install_dependencies
|
|
||||||
cd $PROJECT_NAME
|
|
||||||
install-extra
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_args $1
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
help() {
|
|
||||||
echo "This script installs and sets up the configuration for the repo quaxlyqueen/scripts."
|
|
||||||
echo "It will install the scripts in /usr/local/bin and set up the environment variables and aliases."
|
|
||||||
echo "The user will be prompted to:"
|
|
||||||
echo " - Set up the environment variables and aliases"
|
|
||||||
echo " - Create a theme for supported applications"
|
|
||||||
echo " - Set up Git, github-cli (gh), and gclone"
|
|
||||||
|
|
||||||
echo "\nUsage: sudo ./install"
|
|
||||||
echo " sudo ./install -h | --help"
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# The script must be run as root
|
|
||||||
is_root() {
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
echo "This script must be run as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
create_theme() {
|
|
||||||
USER=$1
|
|
||||||
su $USER -c "mkdir /home/$USER/.config/theme"
|
|
||||||
|
|
||||||
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."
|
|
||||||
|
|
||||||
echo "\nMany themes can be created with this format, and using the 'set-theme <theme>' command."
|
|
||||||
echo "See 'set-theme --help' for more information."
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Install github-cli if it is not already installed
|
|
||||||
check_dependency "gh" "github-cli"
|
|
||||||
|
|
||||||
# If the user has not set up github-cli, do so now
|
|
||||||
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
|
|
||||||
|
|
||||||
# Source the .zshrc file to update the environment
|
|
||||||
source ~/.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
|
|
||||||
}
|
|
||||||
|
|
||||||
is_root
|
|
||||||
if [[ $# -eq 1 ]]; then
|
|
||||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
|
||||||
help
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
more_install
|
|
||||||
if [ -f "install-extra" ]; then
|
|
||||||
echo "Running install-extra..."
|
|
||||||
sudo ./install-extra
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install the scripts
|
|
||||||
echo "Installing scripts..."
|
|
||||||
sudo cp * /usr/local/bin
|
|
||||||
setup_environment
|
|
||||||
more_install
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
TARGET=$1
|
|
||||||
|
|
||||||
if [[ -e $TARGET.mkv ]]; then
|
|
||||||
ffmpeg -i $TARGET.mkv -n $TARGET.mp3
|
|
||||||
rm $TARGET.mkv
|
|
||||||
elif [[ -e $TARGET.webm ]]; then
|
|
||||||
ffmpeg -i $TARGET.webm -n $TARGET.mp3
|
|
||||||
rm $TARGET.webm
|
|
||||||
elif [[ -e $TARGET.mp4 ]]; then
|
|
||||||
ffmpeg -i $TARGET.mp4 -n $TARGET.mp3
|
|
||||||
rm $TARGET.mp4
|
|
||||||
else
|
|
||||||
echo "file not found"
|
|
||||||
fi
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
# Supported languages.
|
|
||||||
TYPES=("c", "rs", "cs", "java", "js", "python", "flutter", "gradle", "go")
|
|
||||||
|
|
||||||
# Catch case where there are too many arguments.
|
|
||||||
if [[ $# -gt 1 ]]; then
|
|
||||||
echo "Proper usage: run {file}"
|
|
||||||
echo " eg. run"
|
|
||||||
echo " eg. run main"
|
|
||||||
echo " eg. run gradle"
|
|
||||||
echo " eg. run flutter"
|
|
||||||
echo " eg. run -h"
|
|
||||||
echo " eg. run --help"
|
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
# Help page
|
|
||||||
elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
|
||||||
echo "\nAbstracting away command line tools to compile and run code for various languages and frameworks."
|
|
||||||
echo "User can use with or without an argument file, the filetype is not needed."
|
|
||||||
echo "With no arguments, 'run' will list available (and supported) files."
|
|
||||||
echo "Additionally, 'run' prompts for and passes command line arguments for a program.\n"
|
|
||||||
echo "Detects required tools to use based upon filetypes.\n"
|
|
||||||
echo "Usage:"
|
|
||||||
echo " run"
|
|
||||||
echo " run [filename]"
|
|
||||||
echo " eg. run main"
|
|
||||||
echo " run gradle"
|
|
||||||
echo " run flutter"
|
|
||||||
echo " run -h"
|
|
||||||
echo " run --help\n"
|
|
||||||
echo "Supported languages: $TYPES"
|
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
# Default state, with a reminder of what files may be launched from based upon the currently supported languages.
|
|
||||||
elif [[ $# -eq 0 ]]; then
|
|
||||||
|
|
||||||
echo "Files that may be launched from:"
|
|
||||||
|
|
||||||
# List files available to launch from.
|
|
||||||
for f in *
|
|
||||||
do
|
|
||||||
TYPE=`echo $f | cut -d "." -f 2`
|
|
||||||
counter=0
|
|
||||||
|
|
||||||
# Only list supported filetypes.
|
|
||||||
if [[ ${TYPES[@]} =~ $TYPE ]]; then
|
|
||||||
counter=$((counter+1)) # Increment counter to indicate the number of results.
|
|
||||||
|
|
||||||
# Format: filename (file type)
|
|
||||||
echo `echo $f | cut -d "." -f 1` "("$TYPE")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo $counter" available files.\n"
|
|
||||||
|
|
||||||
# Catch case where there are no available files to run and exit.
|
|
||||||
if [[ $counter -eq 0 ]]; then
|
|
||||||
echo "No available files to run. Exiting."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
read "?Which file would you like to launch from: " TMP
|
|
||||||
|
|
||||||
# Locate file and assign variables associated with the file (name and filetype).
|
|
||||||
for f in *
|
|
||||||
do
|
|
||||||
FILE=`echo $f | cut -d "." -f 1`
|
|
||||||
if [[ $FILE == $TMP ]]; then
|
|
||||||
NAME=$TMP
|
|
||||||
TYPE=`echo $f | cut -d "." -f 2`
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# User has provided the file name.
|
|
||||||
elif [[ $# -eq 1 ]]; then
|
|
||||||
|
|
||||||
# Locate file and assign variables associated with the file (name and filetype).
|
|
||||||
for f in *
|
|
||||||
do
|
|
||||||
FILE=`echo $f | cut -d "." -f 1`
|
|
||||||
if [[ $FILE == $1 ]]; then
|
|
||||||
NAME=$FILE
|
|
||||||
TYPE=`echo $f | cut -d "." -f 2`
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
read "?Arguments: " ARGS
|
|
||||||
|
|
||||||
# Run C app.
|
|
||||||
if [[ $TYPE == "c" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Compiling..."
|
|
||||||
gcc $NAME.c -lm
|
|
||||||
echo "Output..."
|
|
||||||
./a.out $ARGS
|
|
||||||
|
|
||||||
rm a.out
|
|
||||||
|
|
||||||
# Run a Rust app.
|
|
||||||
elif [[ $TYPE == "rs" ]]; then
|
|
||||||
clear
|
|
||||||
cargo run
|
|
||||||
|
|
||||||
# Run C# app.
|
|
||||||
elif [[ $TYPE == "cs" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Compiling..."
|
|
||||||
mcs -out:$NAME.exe $NAME.cs
|
|
||||||
echo "Output..."
|
|
||||||
mono $NAME.exe
|
|
||||||
|
|
||||||
# Run Java app.
|
|
||||||
elif [[ $TYPE == "java" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Compiling..."
|
|
||||||
javac *.java
|
|
||||||
echo "Output...";
|
|
||||||
java $NAME $ARGS
|
|
||||||
rm *.class
|
|
||||||
|
|
||||||
# Run JavaScript app.
|
|
||||||
elif [[ $TYPE == "js" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Output..."
|
|
||||||
node $NAME.js
|
|
||||||
|
|
||||||
# Run Python app.
|
|
||||||
elif [[ $TYPE == "py" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Running..."
|
|
||||||
python $FILE.py
|
|
||||||
|
|
||||||
# Run Golang app.
|
|
||||||
elif [[ $TYPE == "go" ]]; then
|
|
||||||
clear
|
|
||||||
echo "Compiling..."
|
|
||||||
go build
|
|
||||||
echo "Output..."
|
|
||||||
./discordo #TODO: need to dynamically obtain the newly created object file to run and then delete
|
|
||||||
rm discordo
|
|
||||||
|
|
||||||
# Run app through Gradle
|
|
||||||
elif [[ $1 == "gradle" ]]; then
|
|
||||||
clear;
|
|
||||||
echo "Output..."
|
|
||||||
./gradlew run
|
|
||||||
|
|
||||||
# Run app through Flutter
|
|
||||||
elif [[ $1 == "flutter" ]]; then
|
|
||||||
clear;
|
|
||||||
echo "Output..."
|
|
||||||
flutter run
|
|
||||||
|
|
||||||
else
|
|
||||||
read "?Language is not supported. Create a GH issue (y/n, default y): " GH
|
|
||||||
if [[ $GH == "y" || $GH == "" ]]; then
|
|
||||||
echo "Need to implement issue reporting."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
# This script is used to apply a theme to i3
|
|
||||||
# It takes zero or one argument, the name of the theme to apply or toggle between light and dark
|
|
||||||
# The theme must be located in $THEME_DIR
|
|
||||||
# The theme must be a file with the extension .theme
|
|
||||||
# The theme must be formatted as follows:
|
|
||||||
# base=base_color
|
|
||||||
# accent=accent_color
|
|
||||||
# hover=hover_color
|
|
||||||
# Where base_color, accent_color, and hover_color are hex values
|
|
||||||
# The theme will be applied to i3, i3blocks, and rofi
|
|
||||||
|
|
||||||
cd ~/.config/theme
|
|
||||||
CURRENT_THEME=`stat active.theme | grep .theme | cut -d " " -f 6 | awk -F '/' '{print $NF}'`
|
|
||||||
|
|
||||||
get_current_theme() {
|
|
||||||
if [ -f active.theme ]; then
|
|
||||||
CURRENT_THEME=`stat active.theme | grep .theme | cut -d " " -f 6 | awk -F '/' '{print $NF}'`
|
|
||||||
else
|
|
||||||
ln -sf dark.theme active.theme
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_theme() {
|
|
||||||
get_current_theme
|
|
||||||
# Get the theme
|
|
||||||
theme=$(cat active.theme)
|
|
||||||
|
|
||||||
# Apply the theme
|
|
||||||
base=$(echo $theme | grep -oP '(?<=base=).*')
|
|
||||||
accent=$(echo $theme | grep -oP '(?<=accent=).*')
|
|
||||||
hover=$(echo $theme | grep -oP '(?<=hover=).*')
|
|
||||||
mode=$(echo $CURRENT_THEME | cut -d '.' -f 1)
|
|
||||||
|
|
||||||
# Set i3 themes
|
|
||||||
sed -i "s/color=\(.*\)/color=$hover/g" ~/.config/i3blocks/i3blocks.conf
|
|
||||||
sed -i "s/set \$base .*/set \$base $base/g" ~/.config/i3/config
|
|
||||||
sed -i "s/set \$accent .*/set \$accent $accent/g" ~/.config/i3/config
|
|
||||||
sed -i "s/set \$hover .*/set \$hover $hover/g" ~/.config/i3/config
|
|
||||||
|
|
||||||
# Apply active.theme to alacritty
|
|
||||||
ALACRITTY=~/.config/alacritty
|
|
||||||
sed -i "s/themes\/.*\.toml/themes\/$mode.toml/g" $ALACRITTY/alacritty.toml
|
|
||||||
|
|
||||||
# Apply active.theme to rofi
|
|
||||||
ROFI_PATH=theme.rasi
|
|
||||||
sed -i "s/base\: .*/base: $base\;/" $ROFI_PATH
|
|
||||||
sed -i "s/accent\: .*/accent: $accent\;/" $ROFI_PATH
|
|
||||||
sed -i "s/hover\: .*/hover: $hover\;/" $ROFI_PATH
|
|
||||||
|
|
||||||
# Set NeoVim theme
|
|
||||||
NVIM_PATH=~/.config/nvim/after/plugin/colors.lua
|
|
||||||
if [[ $mode == "light" ]]; then
|
|
||||||
sed -i "s/photon/antiphoton/" $NVIM_PATH
|
|
||||||
sed -i "s/guibg=#262940/guibg=#C6CAED/" $NVIM_PATH
|
|
||||||
sed -i "s/fg='#C6CAED'/fg='#262940'/" $NVIM_PATH
|
|
||||||
else
|
|
||||||
sed -i "s/anti//" $NVIM_PATH
|
|
||||||
sed -i "s/guibg=#C6CAED/guibg=#262940/" $NVIM_PATH
|
|
||||||
sed -i "s/fg='#262940'/fg='#C6CAED'/" $NVIM_PATH
|
|
||||||
fi
|
|
||||||
|
|
||||||
i3-msg restart
|
|
||||||
}
|
|
||||||
|
|
||||||
# If no argument is given, toggle between light and dark
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
if [[ $CURRENT_THEME == "light.theme" ]]; then
|
|
||||||
ln -sf dark.theme active.theme
|
|
||||||
else
|
|
||||||
ln -sf light.theme active.theme
|
|
||||||
fi
|
|
||||||
|
|
||||||
set_theme
|
|
||||||
|
|
||||||
elif [ $# -gt 1 ]; then
|
|
||||||
echo "Too many arguments"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
else
|
|
||||||
# Check if the theme exists
|
|
||||||
if [ ! -f $1.theme ]; then
|
|
||||||
echo "Theme $1 does not exist"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the theme is already applied
|
|
||||||
if [ -f active.theme ]; then
|
|
||||||
if [[ $(cat active.theme) == $(cat $1.theme) ]]; then
|
|
||||||
echo "Theme $1 is already applied"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
ln -sf $1.theme active.theme
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
ln -sf $1.theme active.theme
|
|
||||||
fi
|
|
||||||
|
|
||||||
set_theme
|
|
||||||
fi
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
mkdir dev docs downloads pictures school tmp;
|
|
||||||
sudo pacman -S alacritty android-tools archlinux-keyring aspnet-runtime base blender bluebubbles-desktop-app code dart devhelp devhelp-docs dhcpcd discord docker dotnet-sdk dracut efibootmgr feh firefox flatpak fzf gcc git github-cli godot gradle i3-wm i3lock i3status intel-ucode iwd java-openjfx java-openjfx-doc java-openjfx-src jdk-openjdk jgrasp jre-openjdk keepassxc kubeadm kubectl libreoffice-fresh linux linux-firmware luarocks man-db man-pages maven mono nasm neofetch neovim nerd-fonts-complete-starship net-tools networkmanager network-manager-applet ninja nitrogen nmap npm nvidia obs-studio os-prober php picom pavucontrol pidgin python python-pip reflector rofi rust simplescreenrecorder sof-firmware starship steam sudo tar texinfo thunar tldr typescript unrar vi virtualbox vlc wavpack wget wireshark-cli wl-clipboard xob xorg yarn yay zoom zoxide zsh
|
|
||||||
git clone https://github.com/quaxlyqueen/notes;
|
|
||||||
git clone https://github.com/quaxlyqueen/templates;
|
|
||||||
cd dev; git clone https://github.com/quaxlyqueen/scripts;
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
error() {
|
|
||||||
echo "Improper usage. To increase a value in a file, update [target_file] {+, -}[change]."
|
|
||||||
echo "For example, to increase the volume by 5, use 'update volume +5'."
|
|
||||||
echo "To decrease the brightness by 10, use 'update brightness -10'."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set up target file
|
|
||||||
get_target() {
|
|
||||||
TARGET=$1
|
|
||||||
|
|
||||||
if [[ $TARGET == "volume" ]]; then
|
|
||||||
echo "/home/jashton/.config/xob/volume"
|
|
||||||
|
|
||||||
elif [[ $TARGET == "brightness" ]]; then
|
|
||||||
echo "/home/jashton/.config/xob/brightness"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Invalid target. Please use 'volume' or 'brightness'."
|
|
||||||
error
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Format change
|
|
||||||
get_change() {
|
|
||||||
CHANGE=$1
|
|
||||||
|
|
||||||
if [[ $CHANGE[1] == "+" ]]; then
|
|
||||||
echo $CHANGE[2,-1]
|
|
||||||
return ${CHANGE[2,-1]}
|
|
||||||
elif [[ $CHANGE[1] == "-" ]]; then
|
|
||||||
echo -$CHANGE[2,-1]
|
|
||||||
return -${CHANGE[2,-1]}
|
|
||||||
else
|
|
||||||
echo "Invalid change. Please use '+' or '-'."
|
|
||||||
error
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
update() {
|
|
||||||
CHANGE=$1
|
|
||||||
TARGET=$2
|
|
||||||
TARGET_FILE=$(get_target "$TARGET")
|
|
||||||
|
|
||||||
OLDNUM=`head $TARGET_FILE`
|
|
||||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
|
||||||
|
|
||||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
|
||||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
|
||||||
|
|
||||||
if [[ $TARGET == "volume" ]]; then
|
|
||||||
pamixer --set-volume $NEWNUM%
|
|
||||||
|
|
||||||
elif [[ $TARGET == "brightness" ]]; then
|
|
||||||
brightnessctl set $NEWNUM%
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "Invalid target. Please use 'volume' or 'brightness'."
|
|
||||||
error
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Invalid value. Please use a number between 0 and 100."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for proper number of arguments
|
|
||||||
if [[ $# -ne 2 ]]; then
|
|
||||||
error
|
|
||||||
fi
|
|
||||||
|
|
||||||
TARGET=$1
|
|
||||||
CHANGE=$(get_change "$2")
|
|
||||||
|
|
||||||
# Set up xob
|
|
||||||
tail -f ~/.config/xob/xobpipe | xob -s $TARGET &
|
|
||||||
|
|
||||||
update "$CHANGE" "$TARGET" &
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
tail -f ~/.config/xob/xobpipe | xob -s volume &
|
|
||||||
if [[ $# -eq 2 ]]; then
|
|
||||||
CHANGE=$1
|
|
||||||
TARGET_FILE=$2
|
|
||||||
elif [[ $# -eq 3 ]]; then
|
|
||||||
CHANGE=`expr 0 - $2`
|
|
||||||
TARGET_FILE=$3
|
|
||||||
else
|
|
||||||
echo "Improper usage. To increase a value in a file,\nupdate-bl [change] [target_file]."
|
|
||||||
echo "To decrease a value in a file,\nupdate-bl --decrease [change] [target_file]."
|
|
||||||
fi
|
|
||||||
|
|
||||||
OLDNUM=`cut -f1 $TARGET_FILE`
|
|
||||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
|
||||||
|
|
||||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
|
||||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
|
||||||
brightnessctl set $NEWNUM%
|
|
||||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
|
||||||
fi
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
tail -f ~/.config/xob/xobpipe | xob -s volume &
|
|
||||||
if [[ $# -eq 2 ]]; then
|
|
||||||
CHANGE=$1
|
|
||||||
TARGET_FILE=$2
|
|
||||||
elif [[ $# -eq 3 ]]; then
|
|
||||||
CHANGE=`expr 0 - $2`
|
|
||||||
TARGET_FILE=$3
|
|
||||||
else
|
|
||||||
echo "Improper usage. To increase a value in a file,\nupdate-val [change] [target_file]."
|
|
||||||
echo "To decrease a value in a file,\nupdate-val --decrease [change] [target_file]."
|
|
||||||
fi
|
|
||||||
|
|
||||||
OLDNUM=`cut -f1 $TARGET_FILE`
|
|
||||||
NEWNUM=`expr $OLDNUM + $CHANGE`
|
|
||||||
|
|
||||||
if [[ $NEWNUM -le 100 && $NEWNUM -ge 0 ]]; then
|
|
||||||
sed -i "s/$OLDNUM/$NEWNUM/g" $TARGET_FILE
|
|
||||||
pactl set-sink-volume @DEFAULT_SINK@ $NEWNUM%
|
|
||||||
echo $NEWNUM >> ~/.config/xob/xobpipe
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user