Skip to content

Instantly share code, notes, and snippets.

@GregTheGreek
Last active July 4, 2019 06:20
Show Gist options
  • Save GregTheGreek/fb86239b7a087f7ced9e394e5129319f to your computer and use it in GitHub Desktop.
Save GregTheGreek/fb86239b7a087f7ced9e394e5129319f to your computer and use it in GitHub Desktop.
Bash function to override git clone similar to `go get`
# When gc is run:
# 1) Create a directory from the host if it doesn't exists (github.com, gitlab.com, bitbucket.org, etc...)
# 2) Clone the repository into the host directory based on the repo name
# 3) cd into the newly cloned repository
function gc {
url=$1;
# Choose appropriate path
download_path="~/<YOUR_PATH>/"
full_path=$(echo $url | sed 's/.*@//' | sed -e 's/.git$//' | sed 's/:/\//g')
fpath=$download_path$full_path
git clone $url $fpath
cd $fpath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment