bin/get-wifi-password
#!/usr/bin/env bash
#
# Helper script to print the password for a wifi network on macOS
#
# Apache licensed.
#
# Copyright 2015 Joe Block <jpb@unixorn.net>
#
# This has only been tested on OS X 10.10 Yosemite since I don't have
# anything older.
if [[ "$(uname -s)" = "Darwin" ]]; then
security find-generic-password -ga "$1" 2>&1 | \
grep 'password:' | \
cut -c11-
else
echo "This only works on macOS"
fi