-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathall_git_repos.sh
executable file
·53 lines (48 loc) · 1.02 KB
/
all_git_repos.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
TXTGRN=$(tput setaf 2) # Green
TXTRST=$(tput sgr0) # Text reset.
script_path=`dirname $0`
gitcommand=""
pipe=""
while getopts ":spbBSH" opt; do
case ${opt} in
s )
gitcommand="status -s"
;;
p )
gitcommand="remote -v"
;;
b )
gitcommand="branch -a"
;;
B )
gitcommand="branch -a"
pipe="|grep \*"
;;
S )
gitcommand="show -s"
;;
H )
gitcommand="show -s"
pipe="|grep -B 1 commit"
;;
r )
gitcommand="log --reverse --oneline"
;;
? )
echo "options: [-s] (status) [-p] (paths) [-b] (branches) [-B] (current branch) [-S] (show) [-H] (show hashes) [-r] (log reverse)"
exit
;;
esac
done
pushd $script_path &> /dev/null
pushd .. &> /dev/null
findgit=$(find . -name ".git"|sort)
for x in $findgit; do
pushd $(dirname $x) &>/dev/null
echo -e "${TXTGRN}$(basename $(dirname $x))${TXTRST}"
eval git $gitcommand$pipe
popd &>/dev/null
done
popd &> /dev/null
popd &> /dev/null