lus / pasty

pasty is a fast and lightweight code pasting server
https://pasty.lus.pm
MIT License
200 stars 28 forks source link

Send to pasty from CLI #34

Closed Fastidious closed 2 years ago

Fastidious commented 2 years ago

Is there a way to create a paste from CLI? If so, could I have an example on how to do it? Thanks!

lus commented 2 years ago

Hello.

Yes, you could actually create a shell alias for the following command:

bash -c 'curl -Ls https://pasty.lus.pm/api/v2/pastes -d "{\"content\": \"$(echo $(</dev/stdin))\"}" | echo "https://pasty.lus.pm/$(echo $(</dev/stdin) | jq .id -r)"

If you called your alias paste, you can pipe in any data and receive a paste url like this:

❯ echo "Hello, world" | paste
https://pasty.lus.pm/WX4A5F

Please note that you have to install curl and jq for that.

Fastidious commented 2 years ago

This worked lovely too, thank you very much! This is a good tidbit for a wiki page.