Skip to content

Instantly share code, notes, and snippets.

@FireyFly
Created June 18, 2012 12:52
Show Gist options
  • Save FireyFly/2948243 to your computer and use it in GitHub Desktop.
Save FireyFly/2948243 to your computer and use it in GitHub Desktop.
Utilities
#!/bin/sh
filename=""
case $# in
0) # no arguments; read from stdin into a randomly-named temp file.
tmpfile="/tmp/haste-$(uuidgen | cut -d- -f1)"
filename="$tmpfile"
cat >"$tmpfile"
;;
1) # one argument; assume it's a filename.
filename="$1"
;;
*)
echo "Usage: haste <filename> or foo | haste"
exit 1
esac
# Time to actually upload
curl --data-binary @"$filename" http://hastebin.com/documents \
| sed -r 's|^\{"key":"(.*)"\}$|http://hastebin.com/\1\n|'
# Remove the temporary file used for the paste
if [ "x$tmpfile" != "x" ]; then
rm "$tmpfile"
fi
exit 0
#!/bin/sh
urxvt -e vim "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment