Created
September 15, 2017 15:20
-
-
Save ball6847/a886f6be44cb425a7e63dca9200ea580 to your computer and use it in GitHub Desktop.
Simple bash script to download and extract github repo to local directory, just like "git clone" but only the source code.
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
#!/bin/bash -e | |
if [ -z $1 ]; then | |
echo "skel-hub - download and extract github tarball | |
Usage: $0 user/repo [project]" | |
exit 1 | |
fi | |
GITHUB_REPO=$1 | |
if [ -z $2 ]; then | |
TARGET_NAME=$(basename $GITHUB_REPO) | |
else | |
TARGET_NAME="$2" | |
fi | |
TARGET_DIR=$PWD | |
TMPDIR=$(mktemp -d) | |
cd $TMPDIR | |
wget -qO- "https://github.com/$GITHUB_REPO/archive/master.tar.gz" | tar -zx --strip-components=1 | |
mv $TMPDIR $TARGET_DIR/$TARGET_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example