Created
April 20, 2023 23:54
-
-
Save atomofiron/dfbd6d119e69a4d2fa26ca96556a2adc to your computer and use it in GitHub 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
#!/bin/sh | |
adbpath=$(which adb) | |
if [ -f $adbpath ]; then | |
alias adb='adbrun' | |
fi | |
adbs() { # adb / adb -s ... | |
devices=$($adbpath devices | grep -Po '.+(?=\tdevice)') | |
# make an array | |
devices=( $devices ) | |
if [[ ${#devices[@]} < 2 ]]; then | |
printf $adbpath | |
return | |
fi | |
for i in "${!devices[@]}"; do | |
printf "$i: ${devices[$i]}\n" 1>&2 | |
i=$(($i+1)) | |
done | |
device='' | |
while [[ $device == '' ]]; do | |
printf 'select: ' 1>&2 | |
read | |
device=${devices[$REPLY]} | |
done | |
printf "$adbpath -s $device" | |
} | |
adbrun() { | |
if [[ $* == '' || $* == '--help' || $* == 'devices' ]]; then | |
$adbpath $* | |
return | |
fi | |
$(adbs) $* | |
} | |
lss() { # last screen shot | |
count=$([ $1 ] && printf $1 || printf 1) | |
adbs=$(adbs) | |
while read -r file | |
do | |
$adbs pull "$file" ~/Pictures/Screenshots/ | |
done < <($adbs shell ls -1td /sdcard/Pictures/Screenshots/* | head -n $count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment