#!/usr/bin/env bash while true ; do case $1 in -h|--help) echo "Usage: $(basename "$0") [OPTIONS] [PATH]" echo echo "Print origins of all repositories in PATH." echo echo "Options:" echo " -h --help - print this message and exit" echo " -r --recursive - pull directories recursively" echo exit ;; -r|--recursive) RECURSIVE=-r shift continue ;; -*|--*) echo "Error: unknown option: \"$1\"" >&2 exit ;; *) TARGET_PATH=$1 break ;; esac done TARGET_PATH=${TARGET_PATH:=.} cd "$TARGET_PATH" DIRS=($(git listall ${RECURSIVE})) getOrigin(){ cd "$1" git ls-remote --get-url origin cd "$wd" } # inside a repo... if [ -d ./.git ] ; then echo ". `getOrigin .`" exit 0 fi # no matches... if [[ $DIRS =~ \* ]] ; then echo "no repos found." >&2 exit 1 fi # do the update... wd=$(pwd) for dir in ${DIRS[@]} ; do dir=${dir%.git} echo "$dir `getOrigin "$dir"`" done # vim:set sw=4 ts=4 :