Last active
April 26, 2021 00:22
-
-
Save tgehrs/2b5d7afd51b6955626c4f7fa5dd6beb7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#put this into .bash_profile and then use command adb-screenshot to take an android screenshot | |
#change "Screenshots" below to your target path | |
function adb-screenshot() { adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Screenshots/screen$(date +"%s").png ;} | |
#for zsh | |
function adb-screenshot() { | |
adb shell screencap /sdcard/screen.png | |
adb pull /sdcard/screen.png ~/Screenshots/screen$(date +"%s").png;} | |
function adb-screenshot() { | |
adb shell screencap /sdcard/screen.png | |
adb pull /sdcard/screen.png ~/Screenshots/screen$(date +"%s").png;} | |
function adb-screenrecord() { | |
#name the file | |
filename=screen_record_$(date +"%s").mp4 | |
# start recording | |
adb shell screenrecord /sdcard/$filename & PID=$! | |
# Upon a key press | |
echo "Press [Enter] to stop recording..." | |
read dummy | |
# Kills the recording process | |
kill $PID | |
# Wait for 3 seconds for the device to compile the video | |
sleep 3 | |
# Download the video | |
adb pull /sdcard/$filename ~/Screenshots/$filename | |
# Delete the video from the device | |
adb shell rm /sdcard/$filename | |
# Kill background process incase kill PID fails | |
# trap "kill 0" SIGINT SIGTERM EXIT | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment