diff --git a/run.sh b/run.sh index c783a382788e5f4842917bcef47b75357985308d..ec467c54af256778393d22cdd0f2ce34038a0156 100755 --- a/run.sh +++ b/run.sh @@ -9,7 +9,7 @@ set -e # Import utility script. -source $(dirname $0)/utils.sh +source $(dirname $0)/src/utils.sh ### @@ -34,13 +34,31 @@ function main () { # Display options. echo "" echo -e "${text_blue}Select an option:${text_reset}" + echo -e "${text_cyan}1${text_reset}) Initialize Git" + echo -e "${text_cyan}0${text_reset}) Exit" # Get user input. read user_input - echo "" - echo -e "${text_blue}Exiting program.${text_reset}" - run_script_loop=false + # Handle based on selected option. + if [[ "${user_input}" == "1" ]] + then + pwd + echo "" + # Git initialization. + ./initialize_git.sh + + elif [[ "${user_input}" == "0" ]] + then + echo "" + echo -e "${text_blue}Exiting program.${text_reset}" + run_script_loop=false + else + echo "" + echo -e "${text_red}Unrecognized selection.${text_reset}" + fi + + done diff --git a/src/initialize_git.sh b/src/initialize_git.sh new file mode 100755 index 0000000000000000000000000000000000000000..183be6c700f08a3aa3ebb7d93023a1dc61967b06 --- /dev/null +++ b/src/initialize_git.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +### + # Run basic git initialization. + # The commands are simple in themselves, but I tend to forget about them on initial install. + ## + + +# Abort on error +set -e + + +# Import utility script. +source $(dirname $0)/utils.sh + + + +### + # Program main. + ## +function main () { + + echo "" + echo -e "${text_blue}Setting up basic git configuration.${text_reset}" + + # Install git and tk. + echo -e "${text_blue}Checking apt for git. This may ask for your system password.${text_reset}" + sudo apt install git gitk + + # Set up git email credentials for machine. + user_input="" + while [[ "${user_input}" == "" ]] + do + echo "" + echo -e "${text_cyan}Please provide desired email for git. Ex: \"you@example.com\"${text_reset}" + + # Get user input. + read user_input + done + + echo "git config --global user.email \"${user_input}\"" + git config --global user.email "${user_input}" + + # Set up git name credentials for machine. + user_input="" + while [[ "${user_input}" == "" ]] + do + echo "" + echo -e "${text_cyan}Please provide desired full name for git. Ex: \"Your Name\"${text_reset}" + + # Get user input. + read user_input + done + + echo "git config --global user.name \"${user_input}\"" + git config --global user.name "${user_input}" + +} + + +main diff --git a/utils.sh b/src/utils.sh similarity index 100% rename from utils.sh rename to src/utils.sh