#!/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