summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-12-19 03:11:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-12-20 19:31:05 +0100
commit2bc437df229865456a77fbb982e187aa69304e98 (patch)
tree4a67e6ef5dfc17b84979b81794982f653936086a
parent639c46a342466209e9b0600c2b3574bb44a0ff31 (diff)
downloadpass-2bc437df229865456a77fbb982e187aa69304e98.tar.gz
pass-2bc437df229865456a77fbb982e187aa69304e98.tar.bz2
pass-2bc437df229865456a77fbb982e187aa69304e98.zip
Add extensions
Diffstat (limited to '')
-rw-r--r--man/pass.115
-rwxr-xr-xsrc/password-store.sh15
2 files changed, 27 insertions, 3 deletions
diff --git a/man/pass.1 b/man/pass.1
index 79ea79d..db3158e 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -30,8 +30,12 @@ If no COMMAND is specified, COMMAND defaults to either
.B show
or
.BR ls ,
-depending on the type of specifier in ARGS. Otherwise COMMAND must be one of
-the valid commands listed below.
+depending on the type of specifier in ARGS. Alternatively, if the file
+\fI.extensions/COMMAND.bash\fP exists inside the password store and is executable
+, then it is sourced into the environment, passing any arguments and environment
+variables.
+
+Otherwise COMMAND must be one of the valid commands listed below.
Several of the commands below rely on or provide additional functionality if
the password store directory is also a git repository. If the password store
@@ -385,6 +389,9 @@ Contains the default gpg key identification used for encryption and decryption.
Multiple gpg keys may be specified in this file, one per line. If this file
exists in any sub directories, passwords inside those sub directories are
encrypted using those keys. This should be set using the \fBinit\fP command.
+.TP
+.B ~/.password-store/.extensions
+The directory containing extension files.
.SH ENVIRONMENT VARIABLES
@@ -434,6 +441,10 @@ by \fBtr\fP. See
.BR tr (1)
for more info.
.TP
+.I PASSWORD_STORE_EXTENSION_DIR
+The location to look for executable extension files, by default
+\fIPASSWORD_STORE_DIR/.extensions\fP.
+.TP
.I EDITOR
The location of the text editor used by \fBedit\fP.
.SH SEE ALSO
diff --git a/src/password-store.sh b/src/password-store.sh
index 7b1d5a5..e68a14e 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -13,6 +13,7 @@ which gpg2 &>/dev/null && GPG="gpg2"
[[ -n $GPG_AGENT_INFO || $GPG == "gpg2" ]] && GPG_OPTS+=( "--batch" "--use-agent" )
PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+EXTENSIONS="${PASSWORD_STORE_EXTENSION_DIR:-$PREFIX/.extensions}"
X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}"
CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}"
GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}"
@@ -573,6 +574,18 @@ cmd_git() {
fi
}
+cmd_extension() {
+ local extension="$EXTENSIONS/$1.bash"
+ check_sneaky_paths "$extension"
+ if [[ -f $extension && -x $extension ]]; then
+ shift
+ source "$extension" "$@"
+ else
+ COMMAND="show"
+ cmd_show "$@"
+ fi
+}
+
#
# END subcommand functions
#
@@ -594,6 +607,6 @@ case "$1" in
rename|mv) shift; cmd_copy_move "move" "$@" ;;
copy|cp) shift; cmd_copy_move "copy" "$@" ;;
git) shift; cmd_git "$@" ;;
- *) COMMAND="show"; cmd_show "$@" ;;
+ *) cmd_extension "$@" ;;
esac
exit 0