Skip to content

Instantly share code, notes, and snippets.

@Slowhand0309
Last active October 18, 2020 07:47
Show Gist options
  • Save Slowhand0309/2ea8f62e309ad7ae97f753101757f51e to your computer and use it in GitHub Desktop.
Save Slowhand0309/2ea8f62e309ad7ae97f753101757f51e to your computer and use it in GitHub Desktop.
[Alfred Android emulator] list > run #Alfred
query=$1
source ~/.zshrc
echo -n $query
$ANDROID_SDK/emulator/emulator -avd $query &
EMULATOR_PATH = ENV['ANDROID_SDK'] || ''
if EMULATOR_PATH.empty?
puts 'ANDROID_SDK not set.'
exit
end
def item(index, name)
<<ITEM
<item uid="#{index}" arg="#{name}">
<title>"#{name}"</title>
</item>
ITEM
end
sims = `#{EMULATOR_PATH}/emulator/emulator -list-avds`
items = sims.split(/\R/).map.with_index { |s, i| item(i, s)}.join('')
puts <<EOS
<items>
#{items}</items>
EOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment