Last active
December 16, 2019 15:46
-
-
Save traycho/5c305c8097f39f1789d863c8089e095b to your computer and use it in GitHub Desktop.
Get password from macOS keychain using a bash script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PASSWORD=$(keychainPassword) | |
echo $PASSWORD | |
# Fetch current user password from keychain | |
keychainPassword () { | |
return $(security 2>&1 >/dev/null find-generic-password -ga $USER | sed 's/password: "\(.*\)"/\1/') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment