Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using terms from application "Quicksilver"
- on process text _text
- try
- -- get POSIX path
- set _location to (POSIX path of (path to temporary items from user domain))
- set _filename_unquoted to (_location & _text & ".png")
- -- quoted form for use in shell command
- set _filename to quoted form of _filename_unquoted
- set _command to "screencapture -i " & _filename
- do shell script _command
- set _quoted_text to quoted form of _text
- set _command to "~/bin/imgur.sh " & _filename & " " & _quoted_text
- -- capture output of shell command in variable
- set _url to do shell script _command
- -- copy variable to clipboard
- set the clipboard to _url
- set _file_to_delete to (POSIX file _filename_unquoted) as string
- -- delete image file
- tell application "Finder" to delete _file_to_delete as alias
- tell application "Quicksilver" to show notification "Imgur image uploaded and " & _url & " is on the clipboard"
- -- open in firefox
- tell application "Firefox"
- open location _url
- end tell
- on error a number b
- tell application "Quicksilver"
- activate
- display dialog a
- end tell
- end try
- end process text
- end using terms from
- #!/opt/local/bin/bash
- key="1913b4ac473c692372d108209958fd15"
- file=$1
- if [ "x$file" == "x" ]; then
- echo "Must supply file as first argument"
- exit 1
- fi
- title=$2
- if [ "x$title" == "x" ]; then
- echo "Must supply title as second argument"
- exit 1
- fi
- curl -s -F "image=@-" -F "key=${key}" \
- -F "title=${title}" \
- http://api.imgur.com/2/upload.xml < "$file" | \
- grep -Eo "<imgur_page>(.)*</imgur_page>" | \
- grep -Eo "http://imgur.com/[^<]*"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement