Skip to content

Instantly share code, notes, and snippets.

@readysetawesome
Last active December 13, 2015 23:29

Revisions

  1. readysetawesome revised this gist Feb 20, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions usage.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    # create a gist with file named monday_project.diff,
    # and place the newly created gist URL in my clipboard
    d2g monday_project
  2. readysetawesome revised this gist Feb 20, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion d2g.sh
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,6 @@ function d2g() {
    return
    fi
    curl -H "Authorization: token XXXXtokenWithGistScopeXXXX" -d "{\"description\":\"diff for branch: `git branch | grep \* | sed s/\*\ //g`, created: `date`\",\"public\":false,\"files\":{\"$1.diff\":{\"content\":\"`ruby -e 'require "rubygems";require "json";puts JSON.dump(\`git diff\`)[1..-2]'`\"}}}" https://api.github.com/gists | grep '^ "html_url": "https://gist.github.com' | sed s/\ \ \"html_url\"\:\ \"//g | sed s/\",// | pbcopy
    }
    }

    # build a github token: curl -u 'username' -d '{"scopes":["gist"],"note":"Helper for quick gist from diff"}' https://api.github.com/authorization
  3. readysetawesome created this gist Feb 20, 2013.
    11 changes: 11 additions & 0 deletions d2g.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function d2g() {
    if [ -z "`git diff`" ] ; then
    echo 'There is no diff to publish, brah.'
    return
    fi
    if [ $# -eq 0 ] ; then
    echo 'Please provide a name for the file.'
    return
    fi
    curl -H "Authorization: token XXXXtokenWithGistScopeXXXX" -d "{\"description\":\"diff for branch: `git branch | grep \* | sed s/\*\ //g`, created: `date`\",\"public\":false,\"files\":{\"$1.diff\":{\"content\":\"`ruby -e 'require "rubygems";require "json";puts JSON.dump(\`git diff\`)[1..-2]'`\"}}}" https://api.github.com/gists | grep '^ "html_url": "https://gist.github.com' | sed s/\ \ \"html_url\"\:\ \"//g | sed s/\",// | pbcopy
    }