blob: c8a36bc01ce859cca222f359559f7be95b31a658 (
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
33
34
35
36
|
#!/bin/sh
# To add?
# - possibility of changing verb pull/fetch/push
# - adding prefix
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
ls ~/projects | 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" || exit
git pull > /dev/null 2>&1 &&
printf 'Up to date.' ||
printf 'Couldn'\''t update.'
# Show remote state
printf ' %s %s\n' "$(git status --short 2> /dev/null |
awk 'NR==1 {print $1}')" "$(git branch -v 2>/dev/null |
grep '^\*' | cut -f2 -d'[' | cut -f1 -d' ' |
sed 's/ahead/↑/;s/behind/↓/;s/\*//')"
)
done
|