From 957d360b6d5562358d7062910475b91f3b726bc4 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Thu, 10 Nov 2022 20:39:53 -0500
Subject: [PATCH] Add git configuration option

---
 run.sh                   | 26 ++++++++++++++---
 src/initialize_git.sh    | 60 ++++++++++++++++++++++++++++++++++++++++
 utils.sh => src/utils.sh |  0
 3 files changed, 82 insertions(+), 4 deletions(-)
 create mode 100755 src/initialize_git.sh
 rename utils.sh => src/utils.sh (100%)

diff --git a/run.sh b/run.sh
index c783a38..ec467c5 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 0000000..183be6c
--- /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
-- 
GitLab