Skip to content

Instantly share code, notes, and snippets.

@zkarj735
Last active June 29, 2024 04:51
Show Gist options
  • Save zkarj735/6db9d80816ed4b147fede889efd26ac2 to your computer and use it in GitHub Desktop.
Save zkarj735/6db9d80816ed4b147fede889efd26ac2 to your computer and use it in GitHub Desktop.
A SwiftBar plugin to show how many external disks are connected
#!/bin/zsh
# Get a count of the number of external disks
count=$(df -Hl | grep '^/dev.*\s/Volumes' | wc -l | tr -d '[:space:]')
# Assuming less than 10, turn the number into an SF symbol, e.g. "5.square"
strip=$(echo -n "$count.square")
# Generate a list of the volume names to include in the menu for info
vols=$(df -Hl | grep '^/dev.*\s/Volumes' | sed -e 's|^/dev/.*/Volumes/||' | sort)
# Output
echo ":$strip: | sfcolor=#ffffff sfsize=18\n---\n$vols"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment