I'd like to just check the status of a bunch of Git repos with a quick command like parallel git -C {} status --short ::: ~/*/.git/..
. But the Git status doesn't include the repo name or path, so I'd need some way to print either the git
command run by parallel
or (ideally) just the input (the ~/[…]/.git/..
part of the command) and then the output relevant to that repo. Is this possible? --verbose
will print the command, but doesn't print the command output next to the command, so that's not good enough. And --group
will keep lines from one job together, but doesn't keep those lines together with the command printed by --verbose
, so those two are not enough.
Asked
Active
Viewed 946 times
3

l0b0
- 51,350
2 Answers
3
Try:
parallel --tagstring {//} git -C {//} status --short ::: ~/*/.git
or:
parallel --plus --tagstring {=s:$HOME.::';s:/.git::'=} git -C {//} status --short ::: ~/*/.git
or:
parallel -v git -C {//} status --short ::: ~/*/.git
It is not exactly what you ask for, but may be an acceptable solution.
A solution matching your requirement would be:
parallel "echo {};git -C {} status --short" ::: ~/*/.git/..

Ole Tange
- 35,514
-
Fixed, woot! – l0b0 Nov 05 '22 at 22:43
1
parallel --group --jobs=1 --verbose […]
will print the command, then the command output, then move on to the next command. Disadvantages:
- It won't run any commands in parallel, so it's about as slow as a
for
loop. - It prints the full command rather than just the input.
--verbose
prints the command on standard error, so I'd have to2>&1
to run the output throughless
or a filter.

l0b0
- 51,350