#!/bin/bash
WHITE='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
EXA_PATH="/usr/local/bin/exa"
# bash  <(curl -s https://files.ratchfordconsulting.com/software/software_install/linux/install_bashrc.sh)

echo -e "${WHITE}This script installs exa and appends to ~/.bashrc"
echo -e "${WHITE}You should examine the file and understand it's content before executing${RED}"
read -p "Do you really want to run some sketchy file from the internet? (yes/no) " yn

case $yn in 
	yes ) echo -e "${NC}ok... your funeral";;
	no ) echo -e "${NC}a wise choice...";
		exit;;
	* ) echo invalid response;
		exit 1;;
esac


if [[ ! -f $EXA_PATH ]]; then
    curl -o $EXA_PATH https://files.ratchfordconsulting.com/software/linux_software/exa
    chmod +x $EXA_PATH
fi



curl -o ~/.bashrc.new https://files.ratchfordconsulting.com/software/software_install/linux/.bashrc

if [[ ! -f ~/.bashrc.old ]]; then
    cp ~/.bashrc ~/.bashrc.old
    cat ~/.bashrc.new >> ~/.bashrc
fi

echo -e "${GREEN}Updated ${WHITE}.bashrc${NC}"
echo -e "Backup of your old ${WHITE}.bashrc${NC} can be found at ${WHITE}${HOME}/.bashrc.old${NC}"
echo -e "Please run ${WHITE}source ~/.bashrc${NC} to apply changes"