Created
June 18, 2012 12:52
-
-
Save FireyFly/2948243 to your computer and use it in GitHub Desktop.
Utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| urxvt -e vim "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment