Run once in fish; funcsave keeps it for new sessions.
function pastebin --description 'Upload stdin or a file to Paste'
set -l source -
set -q argv[1]; and set source $argv[1]
curl -q -fsSL -w '\n' --data-binary "@$source" 'https://paste.bea.sh/'
end
funcsave pastebin
Add to ~/.zshrc, then open a new terminal.
pastebin() {
curl -q -fsSL -w '\n' --data-binary "@${1:--}" 'https://paste.bea.sh/'
}
Add to ~/.bashrc, then open a new terminal.
pastebin() {
curl -q -fsSL -w '\n' --data-binary "@${1:--}" 'https://paste.bea.sh/'
}
Standard library only; no packages to install.
import urllib.parse, urllib.request
def paste(text, ttl=None, burn=False, lang="markup"):
params = {"burn": str(burn).lower(), "lang": lang}
if ttl is not None: # None keeps the server default; 0 never expires
params["ttl"] = ttl
query = urllib.parse.urlencode(params)
request = urllib.request.Request(
"https://paste.bea.sh/?" + query, data=text.encode(), method="POST",
headers={"Content-Type": "text/plain"})
with urllib.request.urlopen(request) as response:
return response.read().decode().strip()
print(paste("hello from Python", ttl=3600, lang="python"))