Skip to content

Instantly share code, notes, and snippets.

@thedouglenz
Created July 25, 2015 15:41
Show Gist options
  • Save thedouglenz/c58a0929438804dc7e33 to your computer and use it in GitHub Desktop.
Save thedouglenz/c58a0929438804dc7e33 to your computer and use it in GitHub Desktop.
Atom package manager downloads monitor shell program
#!/bin/bash
#
# A shell program to monitor the number of downloads
# of solarized-seti-ui
#
# Usage: apmdownloads.sh <package-name>
# Douglas Lenz, 2015
#
# First line; will be replaced
echo "Starting...";
PKG_NAME=$1
#
# In a loop, see if we can extract the number of downloads
# from the output of `apm search ...` and, if so, echo it
# to the screen.
#
while [ 1 ]
do
#
# run apm search and save only the line that has the right
# package name
#
SEARCH_OUTPUT="$(apm search -t $PKG_NAME | grep $PKG_NAME)";
# $RE matches "x downloads" where x is any length string of numbers
# Prints on top of the last line, echoing the date along with it to
# ensure that it is still working
RE="([0-9]+ downloads)"
if [[ $SEARCH_OUTPUT =~ $RE ]]; then echo -e "\e[1A\r-------> ${BASH_REMATCH[1]} `date`"; fi
# wait 5 seconds before checking again
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment