Skip to content

Instantly share code, notes, and snippets.

@rustle
Last active October 16, 2025 01:19
Show Gist options
  • Select an option

  • Save rustle/1cc53c41b8f25ff6ef9c86f978e9c47f to your computer and use it in GitHub Desktop.

Select an option

Save rustle/1cc53c41b8f25ff6ef9c86f978e9c47f to your computer and use it in GitHub Desktop.
print table of git branches from remote that haven't been updated in two weeks
#!/bin/sh
REMOTE=$1
REMOTE=${REMOTE:=$(git remote | sed '1s/\s.*$//p')}
TWO_WEEKS_AGO=$(date -v -2w "+%s")
git fetch --prune $REMOTE
printf "\e[1;40;37m| %-45s | %-30s | %-30s |\e[0m\n" "Branch" "Author" "Date"
git for-each-ref \
--sort=committerdate \
refs/remotes/${REMOTE} \
--format='%(committerdate:format:%s)|%(refname:strip=3)|%(authorname)|%(committerdate:relative)' | \
while IFS='|' read -r DATE REFNAME AUTHOR RELATIVE_DATE; do
if [ ${DATE} -lt ${TWO_WEEKS_AGO} ]; then
printf "| %-45.45s | %-30s | %-30s |\n" "${REFNAME}" "${AUTHOR}" "${RELATIVE_DATE}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment