Last active
June 14, 2020 12:02
-
-
Save serrasqueiro/0af3d036f456096502586b481ce0a9f9 to your computer and use it in GitHub Desktop.
Show remote gits
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 | |
# | |
# gitremote.sh -- show remote | |
usage () | |
{ | |
echo "$0 [options] path | |
Options are: | |
- | |
Examples: | |
find prizedseason/ -type d -exec gitremote.sh {} \; | |
-> list remotes under dir prizedseason/ | |
find / -xdev -type d -exec gitremote.sh {} \; | |
-> list all local disk remotes | |
" | |
exit 0 | |
} | |
show_remote () | |
{ | |
local P=$1 | |
if [ "$P" ]; then | |
cd $P | |
[ $? != 0 ] && return 2 | |
if [ -d .git -o -f .git ]; then | |
git remote -v | awk '{print VAL":",$0}' VAL="$P" | \ | |
grep -v "(push)"$ | |
fi | |
fi | |
return 0 | |
} | |
# | |
# Main script | |
# | |
case $1 in | |
-h|--help) | |
usage | |
;; | |
*) | |
show_remote $* | |
RES=$? | |
if [ $RES != 0 ]; then | |
echo "Uops: $*" | |
fi | |
;; | |
esac | |
# Exit status | |
exit $RES | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment