Pastebin It

Tony's Wiki | bash

I made a bash + curl script to paste code to

I saved it as ~/bin/pasteit

Useage is

   :~$ pasteit list

to list all of your pastes


   :~$ pasteit $filename

where $filename is the name of a file you wish to paste.

# script to send text to
# first let's give it some relevant info
# your username, password, a title for your post, and what format (ie. what code language)
read -p "username:  " un
read -sp "password:  " pw
read -p "paste title: " pname
read -p "format (code type): " format
# now let's get a user session key
uk=$(curl -d api_dev_key="$yourAPIkey" -d api_user_name="$un" -d api_user_password="$pw"
# now, either asking for the list,
# or sending the data to paste
if [[ $1 = "list" ]];
		curl -d api_dev_key="$yourAPIkey" -d api_user_key="$uk" -d api_user_name="$un" -d api_user_password="$pw" -d api_option="list"
		pc=$(cat $1)
	curl -d api_dev_key="$yourAPIkey" -d api_user_key="$uk" -d api_user_name="$un" -d api_user_password="$pw" -d api_option="paste" -d api_paste_code="$pc" -d api_paste_name="$pname" -d api_paste_format="$format"

See the actual paste of this code to pastebin, done with this very script, here

I'm trying to figure out how to use this as a vim plugin. I found a vim plugin written in python that was supposed to do this, but it was written before recent changes to the api, so does not work. That was my motivation for trying to create my own plugin. Perhaps I should think about writing one in tcl, since that's my best language, to date…or just try to fix the existing python attempt to work with the new api, and learn some more python fu.

publicly editable talk/discussion page for this script

my pastebin

Now I have my own pastebin at using knoxious free pastebin. The API is different. I posted a script for pasting there at

# © tony baldwin |
# released according to the terms of the 
# Gnu General Public License v. 3
# send text to knoxious free pastebin
# for more info on api see
if [[ $(echo $*) ]]; then
	echo -e "What file, friend? \n "
	read file
text=$(cat $file)
if [[ $(curl -d author=YOURNAME -d pasteEnter="$text" -d lifespan=0 -d highlighter=LANGUAGE http://YOURURL/api-adaptors/sharpshooter.php | egrep error) ]]; then
	echo ERROR
exit 0

tonybaldwin June 18, 2011, at 11:08 PM