Skip to content

Instantly share code, notes, and snippets.

@cwarden
Created February 10, 2012 15:58
Show Gist options
  • Select an option

  • Save cwarden/1790464 to your computer and use it in GitHub Desktop.

Select an option

Save cwarden/1790464 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Upload arbitrary files as a github gist using gisty.
# Returns a bitly link to the gist.
GIST_DIR="$HOME/git/gists"
BITLY_USER=$USER
BITLY_KEY=$(cat $HOME/.bitly_key)
x=$(tempfile)
echo "a gisty gist" > $x
id=$(gisty post $x 2>&1 | awk '{print $3}')
id=${id%%...}
gist_dir=$GIST_DIR/$id
cp "$@" $gist_dir
cd $gist_dir
git rm $(basename $x)
git add *
git ci -m'add extra files to gist'
git push origin
gist_url=https://gist.github.com/$id
url="https://api-ssl.bitly.com/v3/shorten?login=$BITLY_USER&apiKey=$BITLY_KEY&longUrl=$gist_url&format=txt"
curl $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment