Create and maintain a passphrase repository with a single ZSH function.
This Z Shell function allows you to create and maintain a directory of GNU Privacy Guard (GPG) encrypted files. The files can contain anything you want, but I use them to track all my collected passwords and passphrases.
The shell function includes some git functionality. I use these to track revisions and to create a "master" copy of the encrypted files on a remote system. With this, I can keep multiple copies of the files and a simple 'gp --pull' refreshes the local copy with respect to the remote (master).
Initialization
You’ll need to create the the ${PASSFILEDIR} directory and run git init in that directory. Initialization of the remote “master” repository is beyond the scope of this little project (and also not required).
Usage
In order to ensure that the shell function is available in a shell session add this to your ~/.zshrc
autoload gp
compctl -f -W ${PASSFILEDIR} gp
where ${PASSFILEDIR} is the directory in which you keep your encrypted files.
Then simply run gp <name> to decrypt the file “name” and display its cleartext contents to STDOUT. Optionally, type a search string (Perl-compatible regular expression) after <name> (watch the shell special characters).
Options
-a|--append: append to an existing file
-c|--copy|--clip: copy the specified field to the X selection clipboard
-e|--edit: edit an existing file with ${EDITOR}
-d|--diff: run 'git diff' on the whole repo
-h|--help: display a helpful usage message
-n|--new: create a new encrypted file
-g|--no-use-agent: do not use the GPG agent
-l|--pull: run 'git pull'
-p|--push: run 'git push'
-r|--remove: remove a file from the password repository
-t|--status: run 'git status'
--log: run 'git log --name-status'