Skip to content

Instantly share code, notes, and snippets.

@jmesnil
Created October 19, 2009 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmesnil/213420 to your computer and use it in GitHub Desktop.
Save jmesnil/213420 to your computer and use it in GitHub Desktop.
RESP_FILE=/tmp/gist.tmp
rm -f $RESP_FILE
USER=`git config --global github.user`
USERAVAIL=$?
TOKEN=`git config --global github.token`
TOKENAVAIL=$?
if [ $USERAVAIL -eq 0 -a $TOKENAVAIL -eq 0 ]; then
AUTH="--data-urlencode login=$USER --data-urlencode token=$TOKEN"
fi
curl http://gist.github.com/gists --silent -i $AUTH --data-urlencode "file_contents[gistfile1]=$1" --data-urlencode "file_ext[gistfile1]=.txt" -o $RESP_FILE
cat $RESP_FILE|sed -ne '/Location/p'|cut -f2- -d:|tr -d ' ' | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment