matze / wastebin

wastebin is a pastebin
MIT License
250 stars 25 forks source link

Document: How to paste from stdin #51

Closed pinpox closed 2 months ago

pinpox commented 2 months ago

Hey :wave:

I mostly use pastebins when debugging sysemtems to quickly paste logs somewhere to share with coworkers. I used to have a different pastebin which allowed to do something like this:

cat error.log | pastebin-script

Which would paste that text from stdin and print a url with the created past. Is it possible to create such a command for wastebin with curl?

I saw the example for clipboards at https://github.com/matze/wastebin?tab=readme-ov-file#paste-from-clipboard but that is exactly what I need and I have not yet figured out how to make it work.

Maybe you already know how to create an alias or script for this and could document it.

pinpox commented 2 months ago

Answering my own question: This bash function allows pasting by doing cat file.txt | paste:

paste() {
    jq -Rns '{text: inputs}' | curl  -s -H 'Content-Type: application/json' \
        --data-binary @- https://wastebin.tld | jq -r '. | "wastebin.tld\(.path)"'
    }