Last active
August 29, 2015 14:01
-
-
Save andytlr/7f9fa80c2c20b8a2de12 to your computer and use it in GitHub Desktop.
Better OS X Screenshots
This file contains 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
# This will capture a screenshot, put it in your Public Dropbox folder, | |
# reveal it in Finder and copy a sharable URL to the clipboard. E.g. | |
# https://dl.dropboxusercontent.com/u/21267/shots/shot_2014-05-19_12-30-48.png | |
# Uncomment options below for things like opening in Preview, | |
# copying a Markdown/HTML image tag etc. | |
# Replace with your Dropbox user ID. | |
# | |
# Share something from your Public folder to find it. | |
# It's the number following /u/ in the URL. | |
dropboxuser=21267 | |
# The folder inside your public folder you want screenshots to go to. | |
foldername=shots | |
# The filename for each screenshot. Includes date and time to maintain order. | |
filename=shot_`date '+%Y-%m-%d_%H-%M-%S'`.png | |
# Makes the containing directory if it doesn't exist. | |
path=~/Dropbox/Public/$foldername/ | |
mkdir -p $path | |
# Takes the screenshot | |
# | |
# The `-i` sets interactive mode so you can select a region. | |
# Hit space to change to window selection mode. | |
# | |
# The `-o` removes the window shadow from window selections. | |
# If you dig that, remove it. | |
# | |
# Change `-o -i` to `-m` for full screen screenshots instead, | |
# `-m` forces a multi-monitor setup to only capture the main monitor. | |
screencapture -o -i $path$filename | |
# Reveal in Finder | |
open --reveal $path$filename | |
# Open in Preview | |
# open -a 'Preview' $path$filename | |
# Build Dropbox public URL | |
# | |
# It will 404 until the file has finished uploading | |
publicurl=https://dl.dropboxusercontent.com/u/$dropboxuser/$foldername/$filename | |
# Copy URL to clipboard | |
printf $publicurl | pbcopy | |
# Copy Markdown image tag instead | |
# printf "![]($publicurl)" | pbcopy | |
# Copy HTML image tag instead | |
# printf "<img src="$publicurl" alt="" />" | pbcopy | |
# Open the URL in your default browser | |
# open $publicurl |
Various Related Commands
Convert the URL on clipboard to a Markdown image tag
I use Ctrl
+ Opt
+ Cmd
+ i
.
printf "![](`pbpaste`)" | pbcopy
May need to escape the !
by putting a \
before it.
Open output folder
I use Cmd
+ Shift
+ 2
.
open ~/Dropbox/Public/shots/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can be triggered with a hotkey by making an OS X System Service
~/Library/Services
.Cmd
+Shift
+4
to replace the system version.