From 7dc64335388931ee98ebd93f76c6b6454e7cdafd Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 16 Feb 2019 11:33:18 +0100 Subject: [PATCH] Add a helper script to choose the device and run flutter on it It makes the entire process so much easier when you have multiple adb devices. --- scripts/flutter_run.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 scripts/flutter_run.sh diff --git a/scripts/flutter_run.sh b/scripts/flutter_run.sh new file mode 100755 index 00000000..1cafd9c2 --- /dev/null +++ b/scripts/flutter_run.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -eu + +DEVICES=$(adb devices -l | tail -n +2) +NUM_DEVICES=$(echo "$DEVICES" | wc -l) + +if [ "$NUM_DEVICES" = 1 ]; then + DEVICE_ID="$DEVICES" +else + DEVICE_ID=$(echo "$DEVICES" | fzf) +fi + +DEVICE_ID=$(echo "$DEVICE_ID" | awk '{ print $1 }') + +echo "Running on $DEVICE_ID" +flutter run -d "$DEVICE_ID" --pid-file /tmp/flutter.pid --observatory-port 8888 "$@"