summaryrefslogtreecommitdiff
path: root/bin/clone
blob: cfad1afa0b1bce396fc2117a5fbff143be614dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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