Source

bin / sp

Full commit
#!/bin/sh

# sp - sprunge script
# usage: sp [file]
# TIP  : pipe the output through xsel -i to put the url back in to the x
#        selection buffer, add this as a keybinding

# if the x selection contains a file name
if [ $# -eq 0 -a -f "$(xsel)" ]; then
	curl -s -F "sprunge=<$(xsel)" http://sprunge.us

# if the x selection is what we want
elif [ $# -eq 0 ]; then
	xsel | curl -s -F "sprunge=<-" http://sprunge.us

# if we give a filename on the command line
elif [ $# -eq 1 -a -n "$1" -a -f "$1" ]; then
	curl -s -F "sprunge=<$1" http://sprunge.us

# if we want stdin
elif [ $# -eq 1 -a -n "$1" -a "$1" = "-" ]; then
	curl -s -F "sprunge=<-" http://sprunge.us

# if we did something wrong
else
	echo "you did something wrong..."
	exit 1
fi