From b88a6570a49f560c9b8c62ca7d2356fa1f5f0baa Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Wed, 20 Nov 2024 08:39:49 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test(=5Fpush):=20setup=20git=20c?= =?UTF-8?q?onfig=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/config.sh b/config.sh index 890b5a2..7b106fc 100755 --- a/config.sh +++ b/config.sh @@ -1,10 +1,53 @@ #!/bin/bash -# Overwrite false (Merge = true) -git config --global pull.rebase false +# Author: Eshan Roy +# Author URI : https://eshanized.github.io -# Github credential config +set -e -git config --global user.email "m.eshanized@gmail.com" -git config --global user.name "Eshan Roy" +usage() { + echo "Usage: ${0##*/} [--email ] [--username ] [-h]" + echo " --email Set the GitHub user email" + echo " --username Set the GitHub username" + echo " -h Display the help message" + exit 1 +} +while [[ "$#" -gt 0 ]]; do + case "$1" in + --email) + EMAIL="$2" + shift 2 + ;; + --username) + USERNAME="$2" + shift 2 + ;; + -h|--help) + usage + ;; + *) + echo "Unknown argument found: $1" + usage + ;; + esac +done + +# We will ask prompt for email address if not entered by the user +if [ -z "$EMAIL" ]; then + read -p "Enter your GitHub Email: " EMAIL +fi + +# We will ask prompt for username if not entered by the user +if [ -z "$USERNAME" ]; then + read -p "Enter your GitHub Username: " USERNAME +fi + +# Setting up github config +git config --global user.email "$EMAIL" +git config --global user.name "$USERNAME" + +# Get a confirmation message on successful update! +echo "GitHub Configuration setup successfull!" +echo " User Email: $EMAIL" +echo " Username: $USERNAME" \ No newline at end of file