Created
May 18, 2019 21:56
-
-
Save stewSquared/b3dd942982d8a44e6335499d99c5eecc to your computer and use it in GitHub Desktop.
clone github to consistent local directories
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
#!/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