#!/usr/bin/env bash set -Eeuo pipefail trap cleanup SIGINT SIGTERM ERR EXIT script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) cleanup() { trap - SIGINT SIGTERM ERR EXIT # script cleanup here } setup_colors() { if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m' else NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW='' fi } msg() { echo >&2 -e "${1-}" } die() { local msg=$1 local code=${2-1} # default exit status 1 msg "$msg" exit "$code" } setup_colors sudo -n true test $? -eq 0 || exit 1 die "You should have sudo privilege to run this script" msg "${GREEN}\n\nInstalling pre-requisites${NOFORMAT}...\n" # Install required packages while read -r p; do msg "${BLUE}Attempting to install "$p" ${NOFORMAT}..." sudo apt-get install -y "$p" msg "\n" done < <(cat << EOF curl wget vim-gtk3 git tmux zsh universal-ctags build-essential coreutils EOF )