-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.sh
39 lines (32 loc) · 887 Bytes
/
git.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /bin/bash
function git_auto_commit {
local OPTIND a m
local MESSAGE=''
local ALL=''
while getopts "am:" opt; do
case "$opt" in
a)
ALL='a'
;;
m)
MESSAGE=": $OPTARG"
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
#########################################################################
#$(git rev-parse --abbrev-ref HEAD|awk -F '_' '{print "[#"$3"]"}') $(git rev-parse --abbrev-ref HEAD) $MESSAGE
git commit \
-${ALL}m "$(cat <<END_HEREDOC
$(git rev-parse --abbrev-ref HEAD) $MESSAGE
Work stage $(date '+%F %T')
$(git status -s)
END_HEREDOC
)"
}
function git_branch_useful {
for k in `git branch|perl -pe s/^..//`;do
echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;
done|sort -r|column -t
}