theapache64
06/19/2023, 8:15 PMephemient
06/21/2023, 8:22 PMadb logcat
?theapache64
06/23/2023, 12:51 PMephemient
06/23/2023, 2:07 PMlocal output=$(...)
waits until the command is finished, if it's logcat
that's not what you wanttheapache64
06/23/2023, 4:03 PMisMultipleDeviceConnected() && !commandHasSflag()
rather than executing the commandtheapache64
06/23/2023, 4:39 PMfunction adb(){
# executing actual command
local totalLines=$(command adb devices | wc -l | xargs)
local totalDeviceConnected=$(expr $totalLines - 2);
if [[ "$@" != *"-s "* && $totalDeviceConnected -gt 1 ]]; then
# Get the list of connected devices
devices=(`command adb devices | awk '$2 == "device" {print $1}'`)
devicesText=""
# Loop through each device
for device in $devices; do
# Get the market name property
market_name=$(adb -s "$device" shell getprop ro.product.vendor.marketname)
# Check if market name is empty
if [ -z "$market_name" ]; then
# Get the model property if market name is empty
market_name=$(adb -s "$device" shell getprop ro.product.model)
fi
devicesText+="$device - $market_name
"
done
local selection=$(echo $devicesText | fzf)
local deviceId=$(echo $selection | awk '{print $1}')
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo -e "Device Selected: ${GREEN}$selection${NC}"
command adb -s $deviceId "$@"
else
# good to execute command
command adb "$@"
fi
return;
}
ephemient
06/23/2023, 7:05 PMadb kill-server
and there's other ways to select devices like -d
-e
$ANDROID_SERIAL
ephemient
06/23/2023, 7:19 PMadb() {
if command adb get-state >/dev/null 2>&1; then
command adb "$@"
else
command adb -s $(command adb devices -l | awk 'NR>1&&/./' | fzf -1 | cut -d' ' -f1) "$@"
fi
}