Skip to content

Instantly share code, notes, and snippets.

@phouverneyuff
Last active May 4, 2019 16:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phouverneyuff/81805ecb5a0258bf39e7 to your computer and use it in GitHub Desktop.
Save phouverneyuff/81805ecb5a0258bf39e7 to your computer and use it in GitHub Desktop.
gist-upload
#!/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