#!/bin/bash commit() { if ! git diff --quiet || ! git diff --cached --quiet; then # even with -q, it emits a newline into stderr git commit -qam autocommit 2>/dev/null fi } if [[ $1 ]]; then for dir; do cd $dir commit done else commit fi