Quick repository cloning

By Paul English, Fri 28 July 2017, in category Cli

bash, cli, linux, osx, vcs

This is a very simple bash script that I use often whenever I clone a repository. It helps to keep your code organized similar to the way golang programs organize their projects in the GOPATH directory, e.g. $GOPATH/<site>/../../<repo>.


set -e

trap "echo ERRORS DETECTED" err

DIR=$(echo ${URL} | sed \
                        -e "s/https:\/\///g" \
                        -e "s/git@//g" \
                        -e "s/:/\//g" \
                        -e "s/\.git$//g")

git clone "$URL" "$CODEPATH/$DIR"