This post originated from an RSS feed registered with Ruby Buzz
by Obie Fernandez.
Original Post: Quick Commandline Access to Passwords in MacOS
Feed Title: Obie On Rails (Has It Been 9 Years Already?)
Feed URL: http://jroller.com/obie/feed/entries/rss
Feed Description: Obie Fernandez talks about life as a technologist, mostly as ramblings about software development and consulting. Nowadays it's pretty much all about Ruby and Ruby on Rails.
(With some help from Zed) I managed to get this little hack working on my machine to let me quickly access passwords stored in the Keychain. Just add the following function to ~/.bash_profile and you'll be good to go:
function pw {
security find-generic-password -a $1 -g 2>&1 | grep password | cut -d '"' -f2
}
Now whenever you need help remembering a password stored away in your keychain, you can just type pwaccount and it will print out on the console.