summaryrefslogtreecommitdiff
path: root/bin/extra/supd
blob: a383d6542a2c40c629cc313740eb89e9965c863f (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
#!/bin/sh

usage() { >&2 printf "usage: supd\nusage: supd <prefix> <dir>"; exit 1; }

check ()
{
	for dir in $1
	do
		printf '%s: ' "$2/$dir" | sed "s#$HOME#~#" >&2
		cd "$2/$dir" || continue
		git pull > /dev/null 2>&1 &&
			printf 'Up to date.' ||
			printf 'Couldn'\''t update.'
		printf ' '
		git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}'
		printf '\n'
	done
}

if [ "$#" -eq 0 ]
then
	dirs="installdrier dotfiles password-store"
	prefix="$HOME/src"
else
	prefix="$1"
	shift || usage
	dirs="$*"
	[ "$dirs" ] || usage
fi
check "$dirs" "$prefix"