Commit c2b178f
xxwhirlpool
·
2026-09-27 14:43:41 -0400 EDT
parent d3e2c4d
wrapper script to upload tmpfiles to pico.sh pastes
1 files changed,
+24,
-0
+24,
-0
| ... | ... | @@ -0,0 +1,24 @@ | |
| 1 | + | #!/usr/bin/env ruby | |
| 2 | + | ||
| 3 | + | require "tempfile" | |
| 4 | + | ||
| 5 | + | # define tmpfile | |
| 6 | + | tmp = Tempfile.create("pico-pastes-") | |
| 7 | + | tmpfp = tmp.path | |
| 8 | + | ||
| 9 | + | # use $EDITOR, if empty use `nano` | |
| 10 | + | editor = ENV["EDITOR"] ||= "nano" | |
| 11 | + | ||
| 12 | + | # open tmpfile in editor | |
| 13 | + | system("#{editor} #{tmpfp}") | |
| 14 | + | ||
| 15 | + | # check if tmpfile exists or is empty | |
| 16 | + | # if one or the other, exit here | |
| 17 | + | if !File.exist?("#{tmpfp}") || File.empty?("#{tmpfp}") | |
| 18 | + | puts "ERROR: #{tmpfp} does not exist or is empty" | |
| 19 | + | exit 1 | |
| 20 | + | end | |
| 21 | + | ||
| 22 | + | # send to pastes.sh | |
| 23 | + | cmd = "rsync #{tmpfp} pastes.sh:/" | |
| 24 | + | system(cmd) |