【发布时间】:2014-01-27 00:34:14
【问题描述】:
我想通过 IRC 发送我的 OSX 屏幕的部分内容,并且最不费吹灰之力。
许多应用程序已经这样做了:CloudApp、Droplr、DropBox、Jing 等
问题是它们都没有返回指向实际图像的链接。他们返回一个指向包含图像的页面的链接,主要是为了获得广告。这对 IRC 没有好处;大多数 IRC 客户端都很聪明,可以在看到图像的 URL 时显示图像,但它们不够聪明,无法从这样的框架页面中提取图像。
我想写一些东西来做这个。
Shift + Cmd + F3 让我可以用鼠标选择一个矩形,并将图像放置在我的桌面上。这可以更改为另一个文件夹:http://osxdaily.com/2011/01/26/change-the-screenshot-save-file-location-in-mac-os-x/
我想让这张图片自动上传到互联网上,并在我的剪贴板中放置一个 URL 链接。
我解决了一半的问题:以下 bash 脚本将上传一张图片并将链接放入剪贴板:
#! /bin/bash
# Imagebin Loader
# π 27.1.2014
#
# Upload image to imagebin.org, put url to image in clipboard, make noise
filename="$1"
# http://stackoverflow.com/questions/4651437/how-to-set-a-bash-variable-equal-to-the-output-from-a-command
url_out=$(
curl -s \
--form "nickname=$(hostname)" \
--form "image=@$filename;type=$(file --brief -L --mime-type "$filename")" \
--form "disclaimer_agree=Y" \
--form "mode=add" \
--form "Submit=Submit" \
http://imagebin.org/index.php \
-w '%{redirect_url}\n'\
)
# e.g. http://imagebin.org/288917
echo "$url_out"
# http://mywiki.wooledge.org/BashFAQ/073
number=${url_out##*/}
printf -v new_url "http://imagebin.org/index.php?mode=image&id=%s" $number
# e.g. http://imagebin.org/index.php?mode=image&id=288917
echo "$new_url"
#http://osxdaily.com/2007/03/05/manipulating-the-clipboard-from-the-command-line/
printf "$new_url" | pbcopy
say -v Trinoids "Fooo"
现在我该如何完成难题的另一部分:每当桌面上出现新的屏幕截图时,自动执行此脚本?
链接:https://apple.stackexchange.com/questions/118698/free-screen-grabber-for-os-x
【问题讨论】:
标签: macos bash file-upload automation screenshot