#!/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 | awk -F '[][]' '/^\*/ {print $2}')" | sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g' ) done