Skip to content

Instantly share code, notes, and snippets.

@stewSquared
Created May 18, 2019 21:56
Show Gist options
  • 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 "[email protected]:$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