# vim: set ft=sh: { # this ensures the entire script is downloaded # # Source the utility functions if [ -d ~/dotfiles ]; then source ~/dotfiles/utils/utils.sh source ~/dotfiles/utils/install_bashrc.sh source ~/dotfiles/utils/basic_tools.sh source ~/dotfiles/utils/compile_vim.sh source ~/dotfiles/utils/compile_cmake.sh source ~/dotfiles/utils/compile_ycm.sh fi # ################################################################### # MAIN # ################################################################### function main() { clear define_colors banner ech "\nSetting Up..." 2 ech "----------------------------------------------------------------------------" 2 # We need certain functions to run in this file, then we grab the others basic_setup # Source the utility functions if [ -d ~/dotfiles ]; then source ~/dotfiles/utils/utils.sh source ~/dotfiles/utils/install_bashrc.sh source ~/dotfiles/utils/basic_tools.sh source ~/dotfiles/utils/compile_vim.sh source ~/dotfiles/utils/compile_cmake.sh source ~/dotfiles/utils/compile_ycm.sh fi ech "\nInstalling bash..." 2 ech "----------------------------------------------------------------------------" 2 install_bashrc ech "\nInstall completed.\n\n" 2 ech "Please run 'source ~/.bashrc'\n\n" 2 update_vimrc } # ################################################################### # ################################################################### # MUST EXIST IN HERE BECAUSE OF INITAL DOWNLOAD # ################################################################### # ################################################################### # SETUP, GIT, ADD THE REPO # ################################################################### function basic_setup() { tools="curl build-essential git bc dtrx ncdu htop trash-cli tmux bash-completion tig ctags cmake" # silversearcher-ag mactools="curl build-essential git bc dtrx ncdu htop trash-cli the_silver_searcher tmux vim ctags" define_colors if isosx; then which -s brew if [[ $? != 0 ]]; then ech "- Installing Homebrew..." /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi ech "- Install Tools..." brew install --quieter $mactools &> /dev/null ech "- Install iTerm2 Profile..." # Specify the preferences directory defaults write com.googlecode.iterm2.plist PrefsCustomFolder -string "~/dotfiles/iterm2" # Tell iTerm2 to use the custom preferences in the directory defaults write com.googlecode.iterm2.plist LoadPrefsFromCustomFolder -bool true fi # LINUX BASICS # ############################################################# if islinux; then ech "- APT update..." sudo apt-get update ech "- Install Tools.." sudo apt-get install $tools -y fi # GET REPO # ############################################################# if [ ! -d ~/dotfiles ]; then ech "- Cloning dotfiles..." git clone --quiet https://github.com/ryan-frankel/dotfiles ~/dotfiles cd ~/dotfiles else ech "- Pulling dotfiles..." cd ~/dotfiles git pull --quiet origin master fi } # DEFINE BANNER # ################################################################### function banner() { echo -e "${DARKGRAY}" echo -e ".8888b dP dP dP " echo -e "88 ' 88 88 88 " echo -e "88aaa 88d888b. .d8888b. 88d888b. 88 .dP .d8888b. 88 .d8888b. 88d888b. " echo -e "88 88' '88 88' '88 88' '88 88888' 88ooood8 88 Y8ooooo. 88' '88 " echo -e "88 88 88. .88 88 88 88 '8b. 88. ... 88 88 88 88 " echo -e "dP dP '88888P8 dP dP dP 'YP '88888P' dP 88 '88888P' dP dP " echo -e "----------------------------------------------------------------------------" echo -e "${CURSOR}" } # DEFINE COLORS # ################################################################### function define_colors { GREEN="\033[38;05;70m" PURPLE="\033[38;05;93m" LIGHTPURPLE="\033[38;05;105m" LIGHTGRAY="\033[38;05;248m" DARKGRAY="\033[38;05;236m" CURSOR="\033[00m"; CURSOR="${LIGHTGRAY}" } # FUNCTION FOR ECHO WITH COLOR OPTION # ################################################################### function ech() { if [ -z "$2" ]; then echo -e " ${GREEN}$1${CURSOR}"; else echo -e "${CURSOR}$1${CURSOR}"; fi } # FUNCTION TO TEST FOR OSX/LINUX/ETC # ################################################################### function isosx() { if [[ $OSTYPE == *"darwin"* ]]; then return 0; # true else return 1; # false fi } function islinux() { if [[ $OSTYPE == *"linux"* ]]; then return 0; # true else return 1; # false fi } # MAIN CLI Function # ################################################################### # At bottom so all functions are defined when this is run if [ "$1" == "--help" ]; then echo "vim - compile vim and install all bundles" echo "updatevim - Updates vim bundles and vimrc" echo "cmake - install new version of cmake" echo "ycm - install youcompleteme" echo "tools - install basic tools" echo "all - INSTALL ALL THE ABOVE" elif [ "$1" == "updatevim" ]; then update_vimrc elif [ "$1" == "vim" ]; then compile_vim update_vimrc elif [ "$1" == "cmake" ]; then compile_cmake elif [ "$1" == "ycm" ]; then compile_ycm elif [ "$1" == "tools" ]; then basic_tools elif [ "$1" == "all" ]; then basic_tools compile_cmake compile_vim update_vimrc compile_ycm else main fi } # this ensures the entire script is downloaded #