Created
May 22, 2018 06:30
-
-
Save jokester/77b6cb63b1fff8fdf6d00af7a225f0c7 to your computer and use it in GitHub Desktop.
capture screenshot with adb && pull from pc
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
#!/usr/bin/env bash | |
set -ue | |
set -o pipefail | |
temp_basename="screenshot-$(date '+%Y%m%d-%H%M%S-%N').png" | |
temp_remote="/sdcard/$temp_basename" | |
temp_local="/tmp/$temp_basename" | |
( | |
adb shell screencap -p "$temp_remote" | |
adb pull "$temp_remote" "$temp_local" | |
adb shell rm "$temp_remote" | |
echo "screenshot saved at $temp_local" | |
) >&2 | |
if [[ ! -t 1 ]]; then | |
exec cat "$temp_local" | |
else | |
echo "FYI: this script can be used to pipe the new screenshot into a file" | |
echo " e.g. $0 > screen.png" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment