Last active
March 31, 2020 03:26
-
-
Save exapsy/e58d7a67524516cb6356b2e04f7b94ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Prints a raw file from a github repository | |
# usage: gitraw johndoe/myrepo README.md | |
# required: export GITTOKEN, generate a token from github settings | |
function gitraw { | |
GITUSER=$(echo $1 | sed -n "s/\([[:alnum:]]\+\)\/.*/\1/gp") | |
GITREPO=$(echo $1 | sed -n "s/.*\/\([[:alnum:]]\+\)$/\1/gp") | |
GITCONTENT=$2 | |
if [ -z $1 ]; then | |
echo "No path given" | |
else | |
curl -H "Authorization: token $GITTOKEN" \ | |
-H 'Accept: application/vnd.github.v3.raw' \ | |
-L "https://api.github.com/repos/$GITUSER/$GITREPO/contents/$GITCONTENT" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment