diff options
| author | Tslil Clingman <hiato1@gmail.com> | 2013-03-26 15:19:47 +0200 |
|---|---|---|
| committer | Tslil Clingman <hiato1@gmail.com> | 2013-03-26 15:19:47 +0200 |
| commit | 8c19617946822d7aeac61696294f893d5e5eca6f (patch) | |
| tree | c4df5faffc6b335b2c48e2fadd7d6125a33a6056 /ranpas | |
Init scripts
Diffstat (limited to 'ranpas')
| -rwxr-xr-x | ranpas | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#!/bin/bash + +echo Fetching paste list ... +lst="$(wget pastie.org/pastes -q -O - | sed -n "0,/[\ \t]*e=\$('paste_/s///p" | tr -d "');")" +echo Newest paste is $lst. + +while :; do + rnd="$(ruby -e "$><<1+rand($lst)")" + echo -e "\n"Looking up paste $rnd ... + wget http://www.pastie.org/pastes/$rnd/download -q -O /tmp/paste-$rnd + if [ -s "/tmp/paste-$rnd" ]; then + grep -q "<p class=\"notice\">Sorry, there is no pastie #$rnd or it has been removed\. Why not create a new pastie?</p>" /tmp/paste-$rnd + if [ "$?" = "0" ]; then + echo Paste $rnd does not exist. + else + less /tmp/paste-$rnd + echo -n Save?\ + [ "$(line)" = "y" ] && echo Saving as paste $rnd in $HOME && cp /tmp/paste-$rnd $HOME + fi; + else + echo Empty paste. + fi; + rm /tmp/paste-$rnd + echo -n Quit?\ + [ "$(line)" = "y" ] && exit +done; |
