mao
6/23/2017 - 6:43 AM

Get links to gists, CMD.EXE version. Get links to gists of current github user. Dependencies: see comments

Get links to gists, CMD.EXE version. Get links to gists of current github user. Dependencies: see comments

REM Get links to all gists of current github user
REM
REM 2017 Andriy Melnyk https://github.com/TurboBasic
REM
REM Dependencies: Windows 7+, cmd.exe, curl, jq, environment variable
REM         curl: If unsure - use curl from Git for Windows - it works fine.  
REM           jq: JSON command-line parser.  Packages from chocolatey.org and scoop.sh are of excellent quality
REM %githubUser%: default GitHub account to fetch gists from. If not set, fetches 300 random public gists
REM Some useful jq filters, insert them before closing square bracket:
REM                            |select(.filename |startswith(\"box\"))
REM                            |select(.filename |contains("boxstarter.ps1"))
REM                            |select(.filename |test("boxstarter\\.ps1"; "i"))
SETLOCAL
if defined githubUser (
  set __api=https://api.github.com/users/%githubUser%/gists
) else (
  set __api=https://api.github.com/gists
)  
curl %__api% |  jq "[ .[] |.description as $d |.files |{gist_description: $d} + to_entries[].value ]"
ENDLOCAL