Last active
July 4, 2019 06:20
-
-
Save GregTheGreek/fb86239b7a087f7ced9e394e5129319f to your computer and use it in GitHub Desktop.
Bash function to override git clone similar to `go get`
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
# 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