Skip to content

Instantly share code, notes, and snippets.

@mattdanielbrown
Forked from itayd/gistcat
Created November 6, 2023 00:38
Show Gist options
  • Save mattdanielbrown/45d1dee2c6da09c4519f1d1f3d007ad5 to your computer and use it in GitHub Desktop.
Save mattdanielbrown/45d1dee2c6da09c4519f1d1f3d007ad5 to your computer and use it in GitHub Desktop.

Revisions

  1. @itayd itayd revised this gist Dec 14, 2010. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    ssdsd
  2. @itayd itayd revised this gist Dec 14, 2010. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ssdsd
  3. @itayd itayd created this gist Dec 12, 2010.
    23 changes: 23 additions & 0 deletions gistcat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/bin/bash

    notags() {
    while read line; do
    echo $line | sed -e "s/<[^>]*>/ /g" -e "s/ / /g"
    done
    }

    user=$1
    wanted=$2

    list=`curl -s http://gist.github.com/api/v1/xml/gists/${user}`

    repos=`echo $list | xmlstarlet sel -t -c "gists/gist/repo" | notags`

    for repo in $repos; do
    files=`echo $list | xmlstarlet sel -t -c "gists/gist[repo=${repo}]/files/file/file" | notags`
    for file in $files; do
    if [[ $file == $wanted ]]; then
    curl -s https://gist.github.com/raw/$repo/$file
    fi
    done
    done