diff --git a/bin/git-gh-oauth b/bin/git-gh-oauth new file mode 100644 index 0000000..30d9b2a --- /dev/null +++ b/bin/git-gh-oauth @@ -0,0 +1,17 @@ +#!/bin/sh + +user=`git config github.user` +test -z "$user" && echo "failed to fetch github.user" 1>&2 && exit 1 +oauthToken=`git config github.oauthToken` +if [ -z $oauthToken ] ; then + echo "Github oAuth token not found. Creating a new one." + stty_orig=`stty -g` + stty -echo + printf "Github password:" + read passwd + stty $stty_orig + url="https://api.github.com/authorizations" + oauthToken=$(curl -# -u "$user:$passwd" $url -d '{"scopes": ["repo", "user", "gist"]}' | jshon -e token | sed -e 's/"//g') + git config --global github.oauthToken $oauthToken +fi +echo $oauthToken