-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkhaled.sh
More file actions
executable file
·89 lines (73 loc) · 1.74 KB
/
khaled.sh
File metadata and controls
executable file
·89 lines (73 loc) · 1.74 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
file_path="`dirname \"$0\"`"
file_name="khaled.txt"
file="${file_path}/${file_name}"
file_line_count=$(wc -l < ${file})
usage()
{
(echo "git-khaled - Record commits to your repository with DJ Khaled."
echo "USAGE: git khaled [options] <msg>"
echo "OPTIONS:"
echo " --help prints this message"
echo " --one commit another one."
echo " --lion set commit with lion message"
echo " -a, --all automatically stages files that have been modified and deleted"
echo " -q, --quotes outputs all possible patterns"
echo " -k, --key <msg> your message is the key to success") 1>&2
}
if [ $# -le 0 ]; then
echo "Oops! Invalid number of arguments \n"
usage
exit 0
fi
while [ $# -gt 0 ]
do
case $1 in
--usage)
usage
exit 0
;;
-a|--all)
git add -u
;;
-q|--quotes)
cat khaled.txt
exit 0
;;
--lion)
if [ $# -gt 1 ]; then
usage
exit 1
fi
message=":cat: LIIIIION!! :cat:"
;;
--one)
if [ $# -gt 1 ]; then
usage
exit 1
fi
message="ANOTHER ONE."
;;
-k|--key)
if [ $# -gt 2 ] || [ $# -le 1 ]; then
usage
exit 1
fi
message=$(echo ${2} | tr "[:lower:]" "[:upper:]")
message="THE :key: TO SUCCESS IS TO ${message}"
shift 1
;;
*)
if [ $# -gt 1 ]; then
usage
exit 1
fi
file_line_count=$(wc -l < ${file})
let X="${RANDOM} % ${file_line_count} + 1"
message=$(echo ${1} | tr "[:lower:]" "[:upper:]")
message=$(sed -n ${X}p ${file} | sed -e "s/<MESSAGE>/${message}/g")
;;
esac
shift 1
done
git commit -m "${message}"