Skip to content

Instantly share code, notes, and snippets.

@kmaglione
Created September 22, 2011 20:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaglione/1235879 to your computer and use it in GitHub Desktop.
Save kmaglione/1235879 to your computer and use it in GitHub Desktop.
#!/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