Last active
February 17, 2025 07:03
-
-
Save WhoisGray/baacfe37bef7cdef8d7ca542f38d5eb1 to your computer and use it in GitHub Desktop.
๐ Description: This Bash script provides a sleek and interactive way to list Android emulators, navigate through the list using arrow keys, and launch the selected emulator. Itโs designed to simplify the development workflow and enhance productivity.
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
| #!/bin/bash | |
| # ๐ Mobile Emulator Launcher | |
| # Author: WhoisGray | |
| # ๐ Description: A script to list available Android emulators, let you select one using arrow keys, | |
| # and launch the selected emulator seamlessly. | |
| # ๐ ๏ธ Define the path to the emulator command | |
| EMULATOR_PATH="${ANDROID_HOME}/emulator/emulator" | |
| # ๐ Check if the emulator command exists | |
| if [[ ! -x $EMULATOR_PATH ]]; then | |
| echo "โ Error: Emulator command not found at $EMULATOR_PATH." | |
| echo "๐ก Please ensure ANDROID_HOME is correctly set." | |
| exit 1 | |
| fi | |
| # ๐ Fetch the list of available emulators | |
| EMULATORS=$($EMULATOR_PATH -list-avds) | |
| if [[ -z $EMULATORS ]]; then | |
| echo "โ ๏ธ No emulators found. Please create one using the Android Virtual Device Manager." | |
| exit 1 | |
| fi | |
| # ๐น๏ธ Display the list of emulators in a menu | |
| echo "๐ฝ Select an emulator to run:" | |
| EMULATOR_ARRAY=($EMULATORS) | |
| SELECTED_INDEX=0 | |
| while true; do | |
| clear | |
| echo "๐ Available Emulators:" | |
| for i in "${!EMULATOR_ARRAY[@]}"; do | |
| if [[ $i -eq $SELECTED_INDEX ]]; then | |
| echo "โก๏ธ ${EMULATOR_ARRAY[i]}" | |
| else | |
| echo " ${EMULATOR_ARRAY[i]}" | |
| fi | |
| done | |
| # ๐ฎ Read user input | |
| read -rsn1 INPUT | |
| case $INPUT in | |
| A) # โฌ๏ธ Up arrow | |
| if [[ $SELECTED_INDEX -gt 0 ]]; then | |
| SELECTED_INDEX=$((SELECTED_INDEX - 1)) | |
| fi | |
| ;; | |
| B) # โฌ๏ธ Down arrow | |
| if [[ $SELECTED_INDEX -lt $(( ${#EMULATOR_ARRAY[@]} - 1 )) ]]; then | |
| SELECTED_INDEX=$((SELECTED_INDEX + 1)) | |
| fi | |
| ;; | |
| "") # ๐ Enter | |
| SELECTED_EMULATOR="${EMULATOR_ARRAY[SELECTED_INDEX]}" | |
| echo "๐ Starting emulator: $SELECTED_EMULATOR" | |
| $EMULATOR_PATH -avd "$SELECTED_EMULATOR" | |
| exit 0 | |
| ;; | |
| esac | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
๐ Mobile Emulator Launcher Script
๐จโ๐ป Author: WhoisGray
๐ Description
This Bash script offers a streamlined and interactive solution for managing Android Virtual Devices (AVDs). It lists available emulators, allows easy navigation using arrow keys, and launches the selected emulatorโall in one command. Simplify your Android development workflow with this handy tool!
โจ Features
โ๏ธ Prerequisites
ANDROID_HOMEenvironment variable is set and points to your Android SDK directory.๐ Usage
mobile.shor your preferred name.PATHfor global access, or execute it directly.๐ Tags
#bash#android#emulator#developer-tools