Skip to content

Instantly share code, notes, and snippets.

@hasanisaeed
Created February 5, 2022 11:34
Show Gist options
  • Save hasanisaeed/b0e26810dd5003a292a58eefc8a03beb to your computer and use it in GitHub Desktop.
Save hasanisaeed/b0e26810dd5003a292a58eefc8a03beb to your computer and use it in GitHub Desktop.
Custom Git Commit
#!/bin/bash
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
WHITE='\033[0;m'
echo "$RED***** Design by ™Saeed ツ -V0.0.1 *****$WHITE"
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. ◼◼◼◼◼$WHITE"
git push
echo "$GREEN ◼◼◼◼◼ Successfully pushed. ◼◼◼◼◼$WHITE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment