Last active
May 4, 2019 16:29
-
-
Save phouverneyuff/81805ecb5a0258bf39e7 to your computer and use it in GitHub Desktop.
gist-upload
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 | |
# Upload a file informed to gist.github.com. Before use, install gist 'gem install gist' - https://github.com/defunkt/gist and login with gist --login | |
if [ -z $1 ]; then | |
echo "File not informed. E.G: 'gist-upload file1.txt'" | |
exit 0 | |
fi | |
FILE=$1 | |
BASENAME=$(basename -- $1) | |
GIST_URL=$(gist -l | grep ${BASENAME} | awk '{print $1}') | |
#echo BASENAME: $BASENAME | |
#echo FILE: ${FILE} | |
#echo GIST_URL: $GIST_URL | |
if [ -z ${GIST_URL} ]; then | |
gist ${FILE} $2 | |
echo ${FILE} created | |
else | |
gist -u ${GIST_URL} ${FILE} $2 | |
echo ${FILE} updated | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment