Last active
June 12, 2020 18:23
-
-
Save wheresalice/49109603de1f254210fabeaa1388ab4c to your computer and use it in GitHub Desktop.
A shell function for cloning a git repository into a sensible place. `ezclone <repo url>` or `ezclone golang <repo url>`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ezclone() { | |
# assumes cloning from a git@ url... | |
# clone to git_src by default | |
repo_base=~/git_src | |
if [[ "$1" == "golang" ]]; then | |
repo_base=~/go/src | |
shift | |
fi | |
repo=$1 | |
reponame=$(basename $repo .git) | |
repodir=$repo_base/$(dirname $(echo $repo | sed 's/.*@//' | sed 's/:/\//')) | |
if [ -d $repodir/$reponame ]; then | |
echo "$reponame already exists!" | |
else | |
mkdir -p $repodir | |
cd $repodir | |
git clone $repo | |
fi | |
cd $repodir/$reponame | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment