@@ -15,6 +15,7 @@ repositories. By default, mgitstatus scans two directories deep. This can be
15
15
changed with the -d (--depth) option. If DEPTH is 0, the scan is infinitely
16
16
deep.
17
17
18
+ -b Show currently checked out branch
18
19
-c Force color output (preserve colors when using pipes)
19
20
-d, --depth=2 Scan this many directories deep
20
21
-e Exclude repos that are 'ok'
@@ -54,11 +55,15 @@ NO_STASHES=0
54
55
NO_DEPTH=0
55
56
THROTTLE=0
56
57
DEPTH=2
58
+ SHOW_CUR_BRANCH=0
57
59
58
60
while [ -n " $1 " ]; do
59
61
# Stop reading when we've run out of options.
60
62
[ " $( printf " %s" " $1 " | cut -c 1) " != " -" ] && break
61
63
64
+ if [ " $1 " = " -b" ]; then
65
+ SHOW_CUR_BRANCH=1
66
+ fi
62
67
if [ " $1 " = " -c" ]; then
63
68
FORCE_COLOR=1
64
69
fi
@@ -221,6 +226,13 @@ for DIR in "${@:-"."}"; do
221
226
# Refresh the index, or we might get wrong results.
222
227
git --work-tree " $( dirname " $GIT_DIR " ) " --git-dir " $GIT_DIR " update-index -q --refresh > /dev/null 2>&1
223
228
229
+ # Get current branch, if "-b" is specified
230
+ if [ " $SHOW_CUR_BRANCH " -eq 1 ]; then
231
+ CUR_BRANCH=" ($( git --git-dir " $GIT_DIR " rev-parse --abbrev-ref HEAD) )"
232
+ else
233
+ CUR_BRANCH=" "
234
+ fi
235
+
224
236
# Find all remote branches that have been checked out and figure out if
225
237
# they need a push or pull. We do this with various tests and put the name
226
238
# of the branches in NEEDS_XXXX, seperated by newlines. After we're done,
@@ -302,44 +314,44 @@ for DIR in "${@:-"."}"; do
302
314
if [ -n " $NEEDS_PUSH_BRANCHES " ] && [ " $NO_PUSH " -eq 0 ]; then
303
315
THIS_STATUS=" ${C_NEEDS_PUSH} Needs push ($NEEDS_PUSH_BRANCHES )${C_RESET} "
304
316
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
305
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
317
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
306
318
fi
307
319
if [ -n " $NEEDS_PULL_BRANCHES " ] && [ " $NO_PULL " -eq 0 ]; then
308
320
THIS_STATUS=" ${C_NEEDS_PULL} Needs pull ($NEEDS_PULL_BRANCHES )${C_RESET} "
309
321
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
310
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
322
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
311
323
fi
312
324
if [ -n " $NEEDS_UPSTREAM_BRANCHES " ] && [ " $NO_UPSTREAM " -eq 0 ]; then
313
325
THIS_STATUS=" ${C_NEEDS_UPSTREAM} Needs upstream ($NEEDS_UPSTREAM_BRANCHES )${C_RESET} "
314
326
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
315
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
327
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
316
328
fi
317
329
if [ " $UNSTAGED " -ne 0 ] || [ " $UNCOMMITTED " -ne 0 ] && [ " $NO_UNCOMMITTED " -eq 0 ]; then
318
330
THIS_STATUS=" ${C_NEEDS_COMMIT} Uncommitted changes${C_RESET} "
319
331
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
320
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
332
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
321
333
fi
322
334
if [ " $UNTRACKED " != " " ] && [ " $NO_UNTRACKED " -eq 0 ]; then
323
335
THIS_STATUS=" ${C_UNTRACKED} Untracked files${C_RESET} "
324
336
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
325
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
337
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
326
338
fi
327
339
if [ " $STASHES " -ne 0 ] && [ " $NO_STASHES " -eq 0 ]; then
328
340
THIS_STATUS=" ${C_STASHES} $STASHES stashes${C_RESET} "
329
341
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
330
- [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
342
+ [ " $FLATTEN " -eq 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
331
343
fi
332
344
if [ " $STATUS_NEEDS " = " " ]; then
333
345
IS_OK=1
334
346
THIS_STATUS=" ${C_OK} ok${C_RESET} "
335
347
STATUS_NEEDS=" ${STATUS_NEEDS}${THIS_STATUS} "
336
- [ " $FLATTEN " -eq 1 ] && [ " $EXCLUDE_OK " -ne 1 ] && printf " ${PROJ_DIR} : $THIS_STATUS \n"
348
+ [ " $FLATTEN " -eq 1 ] && [ " $EXCLUDE_OK " -ne 1 ] && printf " ${PROJ_DIR} $CUR_BRANCH : $THIS_STATUS \n"
337
349
fi
338
350
339
351
if [ " $FLATTEN " -ne 1 ]; then
340
352
# Print the output, unless repo is 'ok' and -e was specified
341
353
if [ " $IS_OK " -ne 1 ] || [ " $EXCLUDE_OK " -ne 1 ]; then
342
- printf " ${PROJ_DIR} : $STATUS_NEEDS \n"
354
+ printf " ${PROJ_DIR} $CUR_BRANCH : $STATUS_NEEDS \n"
343
355
fi
344
356
fi
345
357
0 commit comments