Skip to content

Instantly share code, notes, and snippets.

@slurpyb
Created January 8, 2025 05:26
Show Gist options
  • Save slurpyb/564654c1c0e88e05c25b53cda5417c8c to your computer and use it in GitHub Desktop.
Save slurpyb/564654c1c0e88e05c25b53cda5417c8c to your computer and use it in GitHub Desktop.
gh-clone
#!/bin/zsh
# CREDIT: https://www.reddit.com/r/git/comments/wgyn0j/comment/ij31p2c/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
# Given a github repo URL, clones the repo in ~/src/<year>/<user>/<repo>
set -eu
repo="$(echo "$1" | sed -r -e 's|https?://github.com/([^/]+)/([^/]+).*|\1/\2|')"
year="$(date +%Y)"
cd ~/src/$year/
mkdir -p "$repo"
cd "$repo"
pwd
cd ..
git clone "ssh://[email protected]/$repo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment