Browse Source

Added the script

Ondřej Hruška 5 years ago
parent
commit
4204fea99a
2 changed files with 101 additions and 1 deletions
  1. 17 1
      README.md
  2. 84 0
      g

+ 17 - 1
README.md View File

@@ -1,4 +1,20 @@
1 1
 lazy-git
2 2
 ========
3 3
 
4
-Script for automating the most common git tasks
4
+Script for automating the most common git tasks.
5
+
6
+Usage
7
+-----
8
+
9
+    # git status
10
+    g check
11
+    
12
+    # git status
13
+    # git add --all
14
+    # git commit -m "...."
15
+    # git push origin master
16
+    g send
17
+    
18
+    # git pull
19
+    g pull
20
+    

+ 84 - 0
g View File

@@ -0,0 +1,84 @@
1
+#!/bin/bash
2
+
3
+function _status {
4
+	echo
5
+
6
+	echo -e "\e[0;33m> git status\e[0m"
7
+	echo
8
+	git status
9
+
10
+	echo
11
+}
12
+
13
+function _pull {
14
+	echo
15
+
16
+	echo -e "\e[0;33m> git pull origin master\e[0m"
17
+	echo
18
+	git pull origin master
19
+
20
+	echo
21
+}
22
+
23
+
24
+function _send {
25
+
26
+	_status
27
+	
28
+	if [ -z "`git status --porcelain`" ]
29
+		then
30
+			echo -e "\e[0;31m Nothing to commit.\e[0m"
31
+			echo
32
+			exit
33
+	fi
34
+
35
+
36
+	echo -e "\e[0;32m Going to ADD all, COMMIT and PUSH.\e[0m"
37
+	echo -e "\e[0;32m Enter commit message (leave blank to abort).\e[0m"
38
+	echo
39
+	echo -n -e "\e[1;36m [msg]: \e[0m"
40
+	read msg
41
+	echo
42
+
43
+	if [ -z "$msg" ]
44
+		then
45
+			echo -e "\e[0;31m Aborted.\e[0m"
46
+			echo
47
+			exit
48
+	fi
49
+
50
+	echo -e "\e[0;33m> git add --all\e[0m"
51
+	echo
52
+	git add --all
53
+	echo
54
+
55
+	echo -e "\e[0;33m> git commit -m \"$msg\"\e[0m"
56
+	echo
57
+	git commit -m "$msg"
58
+	echo
59
+
60
+	echo -e "\e[0;33m> git push origin master\e[0m"
61
+	echo
62
+	git push origin master
63
+	echo
64
+}
65
+
66
+
67
+case $1 in
68
+		"check" | "status")
69
+			_status
70
+			;;
71
+
72
+		"pull")
73
+			_pull
74
+			;;
75
+			
76
+		"send" | "push")
77
+			_send
78
+			;;
79
+
80
+		*)
81
+			echo -e "\n\e[0;31m Invalid ACTION '$1', use one of {check, pull, send} !\e[0m\n";
82
+			;;
83
+
84
+	esac