Skip to content

Instantly share code, notes, and snippets.

@hanshasselberg
Last active January 29, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanshasselberg/f9925baae8a27e30be6e3bf3b1b19f6d to your computer and use it in GitHub Desktop.
Save hanshasselberg/f9925baae8a27e30be6e3bf3b1b19f6d to your computer and use it in GitHub Desktop.
# accepts git urls git@github.com:etcd-io/etcd.git
# accepts https urls https://github.com/etcd-io/etcd
function gclone
set url $argv
switch $url
case "git*"
set path (string replace -r "\.git\$" "" (string replace ":" "/" (string sub -s 5 $url)))
case "https://*"
set path (string sub -s 9 $url)
case '*'
echo 'please provide git or https url'
return 1
end
mkdir -p $GOPATH/src/$path
git clone $url $GOPATH/src/$path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment