Last active
September 15, 2015 21:37
-
-
Save jondb/730ada5b058d0d98e1e6 to your computer and use it in GitHub Desktop.
OSX screen shot to /tmp and reveal in finder. Defaults to window mode and space to change to selector mode
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
query="{query}" | |
if [ $query != '' ]; then | |
/Users/jon/bin/snap -f={query} | |
else | |
/Users/jon/bin/snap | |
fi |
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/bash | |
set -e | |
NOW=$(date +"%m-%d-%H%M%S") | |
OUTDIR=~/Desktop/screenshots | |
OUTFILE_BASE=${OUTDIR}/cap-${NOW} | |
TYPE='png' | |
KIND='-W' | |
ACTION='reveal' | |
for i in "$@" | |
do | |
case $i in | |
-w|--window) | |
KIND="-W" | |
;; | |
-F|--fullscreen) | |
KIND='-m' | |
;; | |
-s|--selection) | |
KIND="-i" | |
;; | |
-P|--pdf) | |
TYPE="pdf" | |
;; | |
-a=*|--action=*) | |
# preview, finder, both, none | |
ACTION="${i#*=}" | |
;; | |
-f=*|--file=*) | |
OUTFILE_BASE="$OUTDIR/${i#*=}" | |
;; | |
*) | |
echo unknown option $i | |
exit -1 | |
;; | |
esac | |
done | |
OUTFILE="$OUTFILE_BASE.$TYPE" | |
OUTDIR=$(dirname $OUTFILE) | |
echo outdir: $OUTDIR | |
mkdir -p $OUTDIR | |
PREVIEW='' | |
if [ "$ACTION" == 'preview' ] || [ "$ACTION" == 'both' ]; then | |
PREVIEW='-P' | |
fi | |
/usr/sbin/screencapture -o $KIND -t $TYPE $PREVIEW "$OUTFILE" | |
if [ "$ACTION" == 'reveal' ] || [ "$ACTION" == 'both' ]; then | |
open -R "$OUTFILE" | |
fi | |
echo $OUTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment