Skip to content

Instantly share code, notes, and snippets.

@hasanisaeed
Created October 14, 2021 12:13
Show Gist options
  • Save hasanisaeed/c113553f3be57fdd2b13d129f437f8a4 to your computer and use it in GitHub Desktop.
Save hasanisaeed/c113553f3be57fdd2b13d129f437f8a4 to your computer and use it in GitHub Desktop.
Git in one line.
#!/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