Skip to content

Instantly share code, notes, and snippets.

@unledrob
Last active February 1, 2017 22:42
Show Gist options
  • Select an option

  • Save unledrob/14ff1c2a418c44fa6fe02293cdbe4268 to your computer and use it in GitHub Desktop.

Select an option

Save unledrob/14ff1c2a418c44fa6fe02293cdbe4268 to your computer and use it in GitHub Desktop.
A bash script for taking screenshots via the Genymotion emulator or iOS Simulator. More info in the comments...
# iOS screenshots to get around El Cap Xcode 8.2.1 issue
# http://stackoverflow.com/a/41125408/84783
# Android / Genymotion screenshots
# http://stackoverflow.com/a/24316765/84783
function ss() {
i="0"
while true; do
filename=~/Desktop/$1_$2_`printf %02d $i`.png
if [ "$1" == "ios" ]; then
xcrun simctl io booted screenshot $filename
else
/Applications/Genymotion.app/Contents/MacOS/tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $filename
fi
echo "Saved $filename..."
i=$[$i+1]
echo "Enter for another screenshot or Ctrl+C to exit"
read
done
}
alias ss=ss
@unledrob

unledrob commented Feb 1, 2017 •

Copy link
Copy Markdown
Author

Genymotion doesn't have an easy way to take screenshots through the GUI, but a really easy command line method. Xcode 8.2.1's Cmd+S method for taking screenshots in the iOS Simulator was broken for El Cap users so I found a nifty command line solution as well. The bash function takes two parameters, the first is platform and the second is a root for the screenshot file name. The function will keep taking screenshots as you ht enter. Ctrl-C to quit. Just put it in your .bash_profile and you're good to go.

Examples...
$ ss ios phone
$ ss android tablet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment