Created
February 25, 2016 07:29
-
-
Save dvoiss/db075db0ff20f258fb18 to your computer and use it in GitHub Desktop.
EMU-laters: Launch multiple Genymotion emulators from the command line with the "emu" command.
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
function emu() { | |
green=$(tput setaf 64) | |
reset=$(tput sgr0) | |
# is VBoxManage available on the machine? | |
if hash VBoxManage 2>/dev/null; then | |
# print the emu: | |
echo "${green}" | |
echo ' | |
/-/-=/-= | |
// ZX " | |
/ /XZXZX(o) ---, | |
/ XZXZXZXZX _____`\ | |
/ZXZXZXZX | |
/ ;,ZXZ EMU-lators | |
/ :ZX%\ | |
/% : X\ | |
:/: %:X:"' | |
echo "${reset}" | |
echo "${green}VirtualBox VMs available:${reset}" | |
echo "" | |
# create list of emulators, remove quotes | |
emulator_list="$(VBoxManage list vms | sed -e 's/"//g')" | |
# iterate through the list of VMs | |
let i=0 | |
emulators=() | |
while read -r line; do | |
(( i ++ )) | |
[[ "$line" =~ (.*)\ {.*} ]] | |
emulators[i]=$line | |
echo "${green}$i${reset}: ${BASH_REMATCH[1]}" | |
done <<< "$emulator_list" | |
echo "" | |
echo "${green}Choose a device by number (1 - $i) or separate multiple choices by a space (\"1 3 4\") to launch multiple emulators:${reset}" | |
echo "" | |
read -a choices | |
echo "" | |
for choice in "${choices[@]}"; do | |
# device_serial=[[ $device =~ {(.*)}$ ]] && echo ${BASH_REMATCH[1]} | |
[[ "${emulators[$choice]}" =~ (.*)\ {.*}$ ]] | |
device_name=${BASH_REMATCH[1]} | |
echo "${green}Using $device_name${reset}" | |
nohup /Applications/Genymotion.app/Contents/MacOS/player.app/Contents/MacOS/player --vm-name "$device_name" &> /dev/null & | |
done | |
else | |
red=$(tput setaf 124) | |
echo "${red}Cannot retrieve list of Genymotion emulators. VirtualBox's VBoxManage must be available.${reset}" | |
fi | |
} |
Author
dvoiss
commented
Feb 25, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment