Skip to content

Instantly share code, notes, and snippets.

@barend
Created July 11, 2016 11:07
Show Gist options
  • Save barend/a101b19a550d039faeabb55d9258860b to your computer and use it in GitHub Desktop.
Save barend/a101b19a550d039faeabb55d9258860b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Adds a bash function that grabs a password from the MacOS keychain.
# Usage:
# getFromKeychain <entryname>
getFromKeychain() {
echo $(security find-generic-password -ga "$1" 2>&1 >/dev/null | awk '/^password/{ print substr($2, 2, length($2) - 2) }')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment