#!/bin/bash

if [ -d /tmp/youyou-scripts/ ]; then
	printf "\e[94mDirectory /tmp/youyou-scripts/ exists, doing nothing.\e[39m"
else
	mkdir -p "/tmp/youyou-scripts/"
	
	for script in bash_profile complete_alias interactions bash_functions bash_colors bash_aliases bash_ffmpeg_functions bash_git_aliases bash_hubert_functions;
	do
		printf "\e[94mFetching youyou script \e[4m${script}.sh\e[24m ...\e[39m"
		if [ ! "$(command -v wget)" = "" ]; then
			wget -q "https://sh.youyou.tf/s/${script}" -O "/tmp/youyou-scripts/${script}.sh"
		elif [ ! "$(command -v curl)" = "" ]; then
			curl -sL "https://sh.youyou.tf/s/${script}" > "/tmp/youyou-scripts/${script}.sh"
		else
			printf "curl -L \"https://sh.youyou.tf/s/${script}\" > \"/tmp/youyou-scripts/${script}.sh\""
		fi
		[[ "$?" = "0" ]] && printf "\e[92m✓ OK\e[39m\n" || printf "\e[91mERROR\e[39m\n"
	done;
	
	for file in /tmp/youyou-scripts/bash_profile.sh ~/.bashrc;
	do
		printf "\e[94mSourcing file \e[4m${file}\e[24m ...\e[39m"
		source "${file}"
		[[ "$?" = "0" ]] && printf "\e[92m✓ OK\e[39m\n" || printf "\e[91mERROR\e[39m\n"
	done;
fi
