Created
October 14, 2021 12:13
-
-
Save hasanisaeed/c113553f3be57fdd2b13d129f437f8a4 to your computer and use it in GitHub Desktop.
Git in one line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Colors | |
GREEN='\033[0;32m' | |
RED='\033[0;31m' | |
WHITE='\033[0;m' | |
helpFunction() { | |
echo "***** USAGE *****" | |
echo "$0 -a add -m '<your message>'" | |
echo "-m Message could not to be empty." | |
exit 1 | |
} | |
while getopts "a:m:" opt; do | |
case "$opt" in | |
a) add="$OPTARG" ;; | |
m) message="$OPTARG" ;; | |
?) helpFunction ;; | |
esac | |
done | |
if [ -z "$add" ]; then | |
add="." | |
fi | |
if [ -z "$message" ]; then | |
echo "$RED >> Oops! Message is empty!$WHITE" | |
helpFunction | |
fi | |
git add "$add" | |
echo "$GREEN ◼◼◼◼◼ Files Added. ◼◼◼◼◼$WHITE" | |
git commit -m "$message" | |
echo "$GREEN ◼◼◼◼◼ Commit Done. ◼◼◼◼◼" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment