Created
March 27, 2014 14:39
-
-
Save ZevEisenberg/9808986 to your computer and use it in GitHub Desktop.
Function to take a screenshot on the currently-connected Android device and drop it on your Mac’s Desktop.
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
function androidScreenshot | |
{ | |
# only do this if there is a device connected | |
adb shell exit 2>/dev/null | |
if [[ $? == 0 ]]; then | |
# Example filename: ~/Desktop/Android Screen 2013-09-11 12.32.16 PM.png | |
# perl line ending hacks from http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html | |
dateString=`date +"%Y-%m-%d at %I.%M.%S %p"` | |
fileName="Android Screen $dateString.png" | |
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/$fileName | |
else | |
echo "No android device connected." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment