Skip to content

Instantly share code, notes, and snippets.

@ninehills
Created May 7, 2010 18:28
Show Gist options
  • Save ninehills/393821 to your computer and use it in GitHub Desktop.
Save ninehills/393821 to your computer and use it in GitHub Desktop.
简单的屏幕截图脚本
#!/bin/bash
#屏幕截图,截取选择区域到 SCRDIR 目录
NOW=`date '+%Y-%m-%d-%H-%M-%S'`
if [ -z $2 ]; then
FNAME=screenshot-${NOW}
else
FNAME="[$2]-${NOW}"
fi
EXT=png
SCRDIR=${HOME}/tmp/snap/
if [ ! -d "${SCRDIR}" ]; then
mkdir -p "${SCRDIR}"
fi
if [ -z $1 ]; then
cmd="import -frame ${SCRDIR}${FNAME}.${EXT}"
else
cmd="import -frame -window $1 ${SCRDIR}${FNAME}.${EXT}"
fi
eval $cmd
echo ${SCRDIR}${FNAME}.${EXT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment