Skip to content

Instantly share code, notes, and snippets.

@aparkerlue
Created January 7, 2022 18:51
Show Gist options
  • Save aparkerlue/0c6ad4a6d8fe30275cdf626568263e43 to your computer and use it in GitHub Desktop.
Save aparkerlue/0c6ad4a6d8fe30275cdf626568263e43 to your computer and use it in GitHub Desktop.
Shell script to list Git repositories
#!/bin/sh
# -*- mode: shell-script; sh-shell: sh; coding: utf-8; -*-
usage() {
echo "Usage: $(basename $0) [-h/--help]"
}
if [ $# -eq 1 ] && ( [ "$1" = "-h" ] || [ "$1" = "--help" ] ); then
usage
echo "List Git repositories."
exit
elif [ $# -gt 0 ]; then
usage >&2
exit 2
fi
find -type d -name .git -exec dirname {} + |
sed 's#^\./##' |
sort |
xargs -r ls -1d --color=auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment