Hi,

I have a couple of custom pass scripts (e.g. a custom clipboard
wizard[1], or a custom file generation script). It would fit perfectly
to the pass workflow if one could call those directly via pass, e.g.

    pass clipwiz Business/some-silly-business-site.com

which should call

    pass-clipwiz Business/some-silly-business-site.com

if there is an executable pass-clipwiz in the PATH. This does not only
fit the usual pass workflow (first show a file, then paste it using
clipwiz), but one also gets the tab-completion for custom pass scripts
for free.

Other command line utilities like git or hledger[2] provide those custom
subcommands, and I'd love to see it in pass as well. I've implemented
that in the attached git formatted patch, but did not know
whether/where/how to add an description for that in the man page.

Feel free to adjust my little patch as you want.

Thank you very much for pass,
Cheers,
Thorsten


[1] http://thorsten-wissmann.de/p/3e7fa904a600c2505b33eda1d4850492
[2] http://hledger.org/manual.html
From 9b96e033a5a6e9e585dc3e1b1057e02a518b3818 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <[email protected]>
Date: Mon, 26 Sep 2016 11:17:37 +0200
Subject: [PATCH] Allow custom subcommands

If called with a subcommand 'cmd', call 'pass-cmd' if such a program is
found in $PATH.
---
 src/password-store.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 63be840..b21250b 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -592,6 +592,13 @@ 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 "$@" ;;
+	*)
+		if which "pass-$1" 2>/dev/null 1>/dev/null ; then
+			shift
+			exec pass-"$COMMAND" "$@"
+		else
+			COMMAND="show";		cmd_show "$@"
+		fi
+		;;
 esac
 exit 0
-- 
2.10.0

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Password-Store mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to