Skip to content

Instantly share code, notes, and snippets.

@lgaggini
Created June 4, 2018 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgaggini/92e54fc29f40b0a61c67a01189b63f00 to your computer and use it in GitHub Desktop.
Save lgaggini/92e54fc29f40b0a61c67a01189b63f00 to your computer and use it in GitHub Desktop.
Retrieve accounts info from pass (passwordstore.org) to be used in dotfiles instead of clear passwords: pass is on the first line, username on the second one.
#! /usr/bin/env python2
# Author: Lorenzo Gaggini
# Version: 0.1
#
# Retrieve accounts info from pass (passwordstore.org)
# to be used in dotfiles instead of clear passwords:
# pass is on the first line, username on the second one.
from subprocess import check_output
import sys
def usage():
print "Usage: %s get_user|get_pass, account" \
% (os.path.basename(sys.argv[0]))
sys.exit(0)
def get_pass(account):
return check_output("pass mail/" + account, shell=True).splitlines()[0]
def get_user(account):
return check_output("pass mail/" + account, shell=True).splitlines()[1]
if __name__ == "__main__":
if len(sys.argv) < 3:
usage()
method = sys.argv[1]
if method == "get_user":
print get_user(sys.argv[2])
elif method == "get_pass":
print get_pass(sys.argv[2])
else:
usage()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment