[PATCH] Load passrc file for configuration purpose

Teubel György tgyurci at gmail.com
Fri Aug 14 10:39:51 CEST 2020


This way PASSWORD_STORE_* variables can be set globally
and configuration does not depend on the invoking environment.

The config files are loaded in this order:
First $XDG_CONFIG_HOME/pass/passrc or $HOME/.config/pass/passrc
then $HOME/.passrc .
---
 man/pass.1            | 4 ++++
 src/password-store.sh | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/man/pass.1 b/man/pass.1
index a555dcb..664a4d3 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -405,6 +405,10 @@ encrypted using those keys. This should be set using the \fBinit\fP command.
 .TP
 .B ~/.password-store/.extensions
 The directory containing extension files.
+.TP
+.B $XDG_CONFIG_HOME/pass/passrc (defaults to to ~/.config/pass/passrc), ~/.passrc
+These files are sourced in order at the beginning.  These can be used to
+define environment variables for configuration (\fIPASSWORD_STORE_*\fP).
 
 .SH ENVIRONMENT VARIABLES
 
diff --git a/src/password-store.sh b/src/password-store.sh
index 77f3eda..f2fb932 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -3,6 +3,9 @@
 # Copyright (C) 2012 - 2018 Jason A. Donenfeld <Jason at zx2c4.com>. All Rights Reserved.
 # This file is licensed under the GPLv2+. Please see COPYING for more information.
 
+[[ -f "${XDG_CONFIG_HOME:-"$HOME/.config"}/pass/passrc" ]] && source "${XDG_CONFIG_HOME:-"$HOME/.config"}/pass/passrc"
+[[ -f "$HOME/.passrc" ]] && source "$HOME/.passrc"
+
 umask "${PASSWORD_STORE_UMASK:-077}"
 set -o pipefail
 
-- 
2.28.0



More information about the Password-Store mailing list