#!/usr/bin/env bash # # foreach # foreach "ls -d */" "git status" # run git status in each folder # # Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach cmd=$1 shift for dir in $($cmd); do ( echo "$dir" cd "$dir" || exit 1 # shellcheck disable=SC2294,SC2034 eval "$@" # allow multiple commands like "foo && bar" ) done