Last active
January 16, 2021 15:27
-
-
Save MAgungHKM/85756afc1d14815e4b8ddfa2539b266b to your computer and use it in GitHub Desktop.
This is a simple Bash function for downloading a specific folder from a GitHub Repository which I created from this [link](https://stackoverflow.com/a/44109535). You can place this inside your bashrc or any other file. As far as testing goes, everything seems to be working fine.
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
# custom download git folder function/command | |
git-grab() { | |
if [ $# -lt 3 ]; then | |
# Display Help | |
echo "This function will download specific folder/directory of a github repo" | |
echo | |
echo "Syntax: git-grab <user-name> <repo-name> <directory> # download from master branch" | |
echo "Syntax: git-grab <user-name> <repo-name> <branch> <directory> # download from a specific branch" | |
echo | |
elif [ $# -eq 3 ]; then | |
wget -O - https://github.com/"$1"/"$2"/archive/master.tar.gz | tar -xz --strip=2 "$2-master/$3"; | |
else | |
wget -O - https://github.com/"$1"/"$2"/archive/"$3".tar.gz | tar -xz --strip=2 "$2-$3/$4"; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment