From 4204fea99a435ff032faec06684735241b8b4450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Fri, 20 Jun 2014 18:02:03 +0200 Subject: [PATCH] Added the script --- README.md | 18 +++++++++++- g | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100755 g diff --git a/README.md b/README.md index ae11d35..446fdb9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,20 @@ lazy-git ======== -Script for automating the most common git tasks +Script for automating the most common git tasks. + +Usage +----- + + # git status + g check + + # git status + # git add --all + # git commit -m "...." + # git push origin master + g send + + # git pull + g pull + diff --git a/g b/g new file mode 100755 index 0000000..65e84e5 --- /dev/null +++ b/g @@ -0,0 +1,84 @@ +#!/bin/bash + +function _status { + echo + + echo -e "\e[0;33m> git status\e[0m" + echo + git status + + echo +} + +function _pull { + echo + + echo -e "\e[0;33m> git pull origin master\e[0m" + echo + git pull origin master + + echo +} + + +function _send { + + _status + + if [ -z "`git status --porcelain`" ] + then + echo -e "\e[0;31m Nothing to commit.\e[0m" + echo + exit + fi + + + echo -e "\e[0;32m Going to ADD all, COMMIT and PUSH.\e[0m" + echo -e "\e[0;32m Enter commit message (leave blank to abort).\e[0m" + echo + echo -n -e "\e[1;36m [msg]: \e[0m" + read msg + echo + + if [ -z "$msg" ] + then + echo -e "\e[0;31m Aborted.\e[0m" + echo + exit + fi + + echo -e "\e[0;33m> git add --all\e[0m" + echo + git add --all + echo + + echo -e "\e[0;33m> git commit -m \"$msg\"\e[0m" + echo + git commit -m "$msg" + echo + + echo -e "\e[0;33m> git push origin master\e[0m" + echo + git push origin master + echo +} + + +case $1 in + "check" | "status") + _status + ;; + + "pull") + _pull + ;; + + "send" | "push") + _send + ;; + + *) + echo -e "\n\e[0;31m Invalid ACTION '$1', use one of {check, pull, send} !\e[0m\n"; + ;; + + esac