Skip to content

Instantly share code, notes, and snippets.

@jschairb
Created February 27, 2009 21:28
Show Gist options
  • Select an option

  • Save jschairb/71709 to your computer and use it in GitHub Desktop.

Select an option

Save jschairb/71709 to your computer and use it in GitHub Desktop.
Grab Password from 1Password
# Grab a password out of the 1Password keychain...finding it by "name"
def password_for_hostname(name)
password_info = `security 2>&1 >/dev/null find-generic-password -gs passwords.Password:#{name} 1Password.keychain`
password = password_info.match(/\"\:\"(.+)\"\}\"/)[1] rescue nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment