Skip to content

Instantly share code, notes, and snippets.

@FokkeZB
Created October 3, 2014 13:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FokkeZB/86713457bf84808a12a6 to your computer and use it in GitHub Desktop.
Save FokkeZB/86713457bf84808a12a6 to your computer and use it in GitHub Desktop.
Alias for making screenshots from connected Android device/emulator
alias screenshot='adb shell screencap -p | perl -pe "s/\x0D\x0A/\x0A/g" > "/Users/fokkezb/Downloads/android_$(date +%Y%m%d-%H%M%S).png"'
# NOTE: Replace 'fokkezb' with your user. You cannot use ~ when using $() unfortunately
@skypanther
Copy link

Stating the obvious, you can save to the desktop rather than downloads with:

adb shell screencap -p | perl -pe "s/\x0D\x0A/\x0A/g" > "/Users/YOURUSERNAME/Desktop/android_$(date +%Y%m%d-%H%M%S).png"

@skypanther
Copy link

I know this is an old gist, but still handy. Here's a better way to do this without hard-coding the path to your user's directory:

# take a screencap of a connected Android device
alias screenshot='adb shell screencap -p | perl -pe "s/\x0D\x0A/\x0A/g" > "$HOME/Desktop/android_$(date +%Y%m%d-%H%M%S).png"'

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