#!/bin/bash set -eu args=() for url in "$@" do case $url in https://*|git://*) dir=${url#*//} dir=${dir%/*} ;; git@*) dir=${url#git@} dir=${dir/://} dir=${dir%/*} ;; *) args+=("$url") continue esac mkdir -vp ~/src/"$dir" cd ~/src/"$dir" git clone --verbose --progress "${args[@]}" "$url" args=() done