From a179073e10b059b55bdffe556e326069e00b14b3 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Sat, 23 Nov 2024 11:49:13 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(=5Fblank):=20forgot=20t?= =?UTF-8?q?o=20save?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git-config.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/git-config.sh b/git-config.sh index e69de29..ece8d8a 100755 --- a/git-config.sh +++ b/git-config.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +# Author: Eshan Roy +# Description: This script configures GitHub user email and username. + +set -e + +# Function to display usage +usage() { + echo "Usage: ${0##*/} [--email ] [--username ] [-h]" + echo " --email Set the GitHub user email." + echo " --username Set the GitHub username." + echo " -h Display this help message." + exit 1 +} + +# Parse command line arguments +while [[ "$#" -gt 0 ]]; do + case "$1" in + --email) + EMAIL="$2" + shift 2 + ;; + --username) + USERNAME="$2" + shift 2 + ;; + -h|--help) + usage + ;; + *) + echo "Unknown parameter passed: $1" + usage + ;; + esac +done + +# Prompt for email if not provided +if [ -z "$EMAIL" ]; then + read -p "Enter your GitHub email: " EMAIL +fi + +# Prompt for username if not provided +if [ -z "$USERNAME" ]; then + read -p "Enter your GitHub username: " USERNAME +fi + +# Set the Git configuration +git config --global user.email "$EMAIL" +git config --global user.name "$USERNAME" + +# Confirmation message +echo "GitHub configuration updated:" +echo " User Email: $EMAIL" +echo " Username: $USERNAME" \ No newline at end of file