#!/bin/bash # Author: Alexander Epstein https://github.com/alexanderepstein setvar currentVersion = ""1.11.1"" declare -a tools=(currency stocks weather crypt movies taste short geo cheat ytview cloudup qrify) proc askInstall { echo -n "Do you wish to install $1 [Y/n]: " read -r answer if [[ "$answer" == "Y" || "$answer" == "y" ]] { cd $1 || return 1 echo -n "Installing $1: " chmod a+x $1 cp $1 /usr/local/bin > /dev/null 2>&1 || do { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; } echo "Success" cd .. || return 1 } } proc updateTool { if [[ -f /usr/local/bin/$1 ]]{ cd $1 || return 1 echo -n "Installing $1: " chmod a+x $1 cp $1 /usr/local/bin > /dev/null 2>&1 || do { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; } echo "Success" cd .. || return 1 } } proc singleInstall { cd $1 || exit 1 echo -n "Installing $1: " chmod a+x $1 cp $1 /usr/local/bin > /dev/null 2>&1 || do { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; } echo "Success" cd .. || exit 1 } proc copyManpage { cp bash-snippets.1 /usr/local/man/man1 2>&1 || do { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; } } if [[ $# == 0 ]] { for tool in "${tools[@]}" { askInstall $tool || exit 1 } copyManpage || exit 1 } elif [[ $1 == "update" ]] { echo "Updating scripts..." for tool in "${tools[@]}" { updateTool $tool || exit 1 } copyManpage || exit 1 } elif [[ $1 == "all" ]]{ for tool in "${tools[@]}" { singleInstall $tool || exit 1 } copyManpage || exit 1 } else { singleInstall $1 || exit 1 copyManpage || exit 1 } echo -n "( •_•)" sleep .75 echo -n -e "\r( •_•)>⌐■-■" sleep .75 echo -n -e "\r " echo -e "\r(⌐■_■)" sleep .5 echo "Bash Snippets version $currentVersion" echo "https://github.com/alexanderepstein/Bash-Snippets"