-
-
Save aparkerlue/0c6ad4a6d8fe30275cdf626568263e43 to your computer and use it in GitHub Desktop.
Shell script to list Git repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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