blob: e8eacd4198607fff41660730e1daee45b9d19386 (
plain)
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
|
#!/bin/sh
ls() { find . -mindepth 1 -maxdepth 1 -type d -not -name ".*" -printf '%f\n'; }
if [ "$1" = '-h' ]
then
>&2 cat <<-EOF
usage:
supd Update dirs in current dir
... | supd Update dirs read from stdin
supd -h Show help
EOF
exit
fi
[ ! -t 0 ] && dirs="$(cat)" || dirs="$(ls)"
for dir in $dirs
do
printf '%s:' "$dir" | >&2 sed "s#$HOME#~#"
(
cd "$dir" || return
git "${1:-fetch}" > /dev/null 2>&1 &&
printf ' o' ||
printf ' x'
# Show remote state
printf '%s %s\n' "$(git status --short 2> /dev/null |
awk 'NR==1 {print $1}')" "$(git branch -v 2>/dev/null |
awk -F '[][]' '/^\*/ {print $2}')" |
sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g'
)
done
|