,gitclone(){ if [[ "$1" =~ ^git@github.com ]]; then local repo=$(echo $1 | grep -Po '(?<=git@github\.com:)[\w-]+\/[\w-]+') local origin_url=$1 elif [[ $1 =~ ^https://github.com ]]; then local repo=$(echo $1 | grep -Po '(?<=https:\/\/github\.com\/)[\w-]+\/[\w-]+') local origin_url=$1 elif [[ $1 == "gh" ]]; then local repo=${4} local origin_url="git@github.com:$repo.git" else echo "Url isn't vaild." fi local repo_name=$(echo $repo | grep -Po '(?<=\/)[\w-]+') local new_url="https://gitclone.com/github.com/$repo.git" echo "start downloading : ${repo}" && git clone $new_url if [ -d $repo_name ] && [ $? == 0 ]; then cd ./$repo_name && git remote rename origin mirror && git remote add origin $origin_url && cd - fi }