@@ -18,6 +18,7 @@ cdc() {
18
18
local dir
19
19
local list
20
20
local directory
21
+ local subdir
21
22
local wdir
22
23
local marker
23
24
local cdc_last_element
@@ -33,6 +34,7 @@ cdc() {
33
34
local which=false
34
35
local cdc_current=false
35
36
local cdc_pop=false
37
+ local cdc_git_status=false
36
38
local cdc_show_history=false
37
39
local cdc_list_ignored=false
38
40
local print_help=false
@@ -55,7 +57,7 @@ cdc() {
55
57
# If argument contains a slash, it's assumed to contain subdirectories.
56
58
# This splits them into the directory root and its subdirectories.
57
59
if [[ " $1 " == * /* ]]; then
58
- local subdir=" ${1#*/ } "
60
+ subdir=" ${1#*/ } "
59
61
fi
60
62
61
63
# #
@@ -68,7 +70,7 @@ cdc() {
68
70
69
71
# #
70
72
# Case options if present. Suppress errors because we'll supply our own.
71
- while getopts ' acCdDhilLnprRstuUw ' opt 2> /dev/null; do
73
+ while getopts ' acCdDghilLnprRstuUw ' opt 2> /dev/null; do
72
74
case $opt in
73
75
74
76
# #
@@ -83,6 +85,10 @@ cdc() {
83
85
# -C: Disable color.
84
86
C) use_color=false ;;
85
87
88
+ # #
89
+ # -g: Display git status for each repo.
90
+ g) cdc_git_status=true ;;
91
+
86
92
# #
87
93
# -n: cd to the root of the current repository in the stack.
88
94
n) cdc_current=true ;;
@@ -236,6 +242,8 @@ cdc() {
236
242
echo ' | List all directories that are to be ignored.'
237
243
printf " ${CDC_WARNING_COLOR} -d${CDC_RESET} "
238
244
echo ' | List the directories in stack.'
245
+ printf " ${CDC_WARNING_COLOR} -g${CDC_RESET} "
246
+ echo ' | Cycle through all repositories and print git status.'
239
247
printf " ${CDC_WARNING_COLOR} -n${CDC_RESET} "
240
248
echo ' | `cd` to the current directory in the stack.'
241
249
printf " ${CDC_WARNING_COLOR} -p${CDC_RESET} "
@@ -262,6 +270,29 @@ cdc() {
262
270
return 0
263
271
fi
264
272
273
+ if $cdc_git_status ; then
274
+ if $debug ; then
275
+ _cdc_print ' success' ' Showing git status' $debug
276
+ fi
277
+ dir=" $PWD "
278
+ for directory in " ${CDC_DIRS[@]} " ; do
279
+ [[ -d $directory ]] || continue
280
+ pushd " $directory " > /dev/null
281
+ for subdir in * /; do
282
+ if ! $allow_ignored && _cdc_is_excluded_dir " $subdir " ; then
283
+ continue
284
+ fi
285
+ [[ -d $subdir /.git ]] || continue
286
+ printf " \n\n>> Checking status of [%s] <<\n" " $subdir "
287
+ pushd " $subdir " > /dev/null
288
+ git status
289
+ popd > /dev/null
290
+ done
291
+ popd > /dev/null
292
+ done
293
+ should_return=true
294
+ fi
295
+
265
296
if $cdc_list_searched_dirs ; then
266
297
if $debug ; then
267
298
_cdc_print ' success' ' Listing searched directories.' $debug
0 commit comments