diff options
Diffstat (limited to 'gen-setup.sh')
| -rwxr-xr-x | gen-setup.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gen-setup.sh b/gen-setup.sh new file mode 100755 index 0000000..00d2cf7 --- /dev/null +++ b/gen-setup.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +columate() { + _str="$1" + + _max_length=48 + _length=$( printf "%s" $_str | wc -c) + # Divide by 8, because that's the standard tabstop + _tab_num=$(echo "($_max_length-$_length)/8" | bc -l ) + _tabs="" + + # Create the tabs + for _tab in $( seq $_tab_num ) ; do + _tabs="$(printf "%s\t" $_tabs)" + done + + # "Return" the tabs + printf "%s" $_tabs +} + +REPOS="$(find . -iname .git -type d | sed -e's/\/\.git$//' -e's_./__')" + +WD="$(pwd)" + +IFS=' +' + +echo '#!/bin/sh + +WD="$(pwd)" + +clone() { + printf "\033[0mWorking dir: \033[1;34m%s\033[0;33m\n" $DIR + if [ -d "$DIR" ] ; then + cd $DIR + git pull --ff-only origin master + elif ! [ -d "$DIR" ] ; then + mkdir -p "$DIR" + cd "$DIR" + git clone "$URL" . + fi + cd $WD +}' > setup.sh + +for _repo in $REPOS; do + cd "$_repo" + # I've probably made dangerous assumptions here, but whatever. + URL="$(git remote --verbose| awk '{print $2}' | sort | uniq | head -n 1)" + cd "$WD" + + _tabs="$(columate $_repo)" + + printf 'Added: \033[1;33m%s\033[0m%sURL: \033[1;34m%s\033[0m\n' \ + $_repo $_tabs $URL + printf 'DIR="%s"\nURL="%s"\nclone\n' $_repo $URL >> setup.sh +done + + +chmod +x setup.sh |
