Created
September 22, 2011 20:07
-
-
Save kmaglione/1235879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/rc | |
. 9.rc | |
. rclib $* | |
getflags 'g,p,r,e expire,n nick,d desc,l lang' | |
ext='' | |
if (~ $flage '') flage = N | |
if (! ~ $flagl '') ext=.$flagl | |
name=stdin | |
if (! ~ $#argv 0) | |
name = $argv(0) | |
ifs='' | |
js -e ' | |
let data = { | |
public: !environment.flagp, | |
description: environment.flagd, | |
files: {} | |
}; | |
let { ext } = environment; | |
if (!scriptArgs.length) { | |
let line, lines = []; | |
while ((line = readline()) != null) | |
lines.push(line); | |
data.files["stdin" + ext] = { content: lines.join("\n") }; | |
} | |
else for each (let arg in scriptArgs) | |
data.files[arg + ext] = { content: read(arg) }; | |
print(JSON.stringify(data)); | |
' /dev/null $argv | | |
curl -nd '@-' https://api.github.com/gists | | |
js -e ' | |
let line, lines = []; | |
while ((line = readline()) != null) | |
lines.push(line); | |
let json = JSON.parse(lines.join("\n")); | |
if (environment.flagg) | |
print(json.git_pull_url); | |
else if (environment.flagr) | |
print([f.raw_url for each (file in json.files)].join(" ")); | |
else | |
print(json.html_url); | |
' | | |
tee >{tr -d $newline | xsel -i} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment