Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created April 20, 2015 17:22
Show Gist options
  • Select an option

  • Save tjluoma/139877856de1955b6946 to your computer and use it in GitHub Desktop.

Select an option

Save tjluoma/139877856de1955b6946 to your computer and use it in GitHub Desktop.
#!/bin/zsh -f
# Purpose: Show the number of mounted devices (not including boot drive)
# Intended to be used with TextBar - http://www.richsomerfield.com/apps/
COUNT=`/sbin/mount | /usr/bin/egrep -v '^(devfs|map) ' | /usr/bin/wc -l | /usr/bin/tr -dc '[0-9]'`
# We don't want to count the boot drive, so subtract 1
COUNT=$(($COUNT - 1))
if [ "$COUNT" = "0" ]
then
echo -n "No Mounts"
elif [ "$COUNT" = "1" ]
then
echo -n "1 Mount"
else
echo -n "$COUNT Mounts"
fi
exit 0
#
#
# From: Tj Luo.ma
# Mail: luomat at gmail dot com
# Web: http://RhymesWithDiploma.com
# Date: 2015-04-18
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment