Skip to content

Instantly share code, notes, and snippets.

@stewSquared
Created May 18, 2019 21:56
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 stewSquared/b3dd942982d8a44e6335499d99c5eecc to your computer and use it in GitHub Desktop.
Save stewSquared/b3dd942982d8a44e6335499d99c5eecc to your computer and use it in GitHub Desktop.
clone github to consistent local directories
#!/usr/bin/bash
clone-github () {
local -r user_repo=$(sed -e "s|.*github.com/||" <<< $1)
local -r dest="$HOME/github.com/$user_repo"
if [[ -e $dest ]]; then
echo "$dest already exists"
echo "cd -- $dest"
cd $dest
return 1
else
git clone "git@github.com:$user_repo.git" $dest\
&& cd $dest
fi
}
alias gh=clone-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment