On Mon, Feb 2, 2015 at 5:58 PM, Étienne Deparis <[email protected]> wrote:
>
> Hi!
>
> I use intensively pass, which is a clever solution to password
> management. However I miss a feature, which allow me to quickly get
> password information when I know the pass file, but forgot (or don't
> want to remember) its position in the password tree.
>
> Thus, I propose the attached patch, which add an option to the "show"
> command in order to display the content of the first file matching the
> path parameter. Sort of "I'm lucky" thing for my password bucket.

Hi Etienne, List,

I implemented something very similar on my local pass some time ago.
This is a good opportunity to post it to the list. It's only 5 lines
added to the
show function. Please note that the man/documentation is not updated, and that
the code/patch is probably note formatted as it should be.

The attached patch changes the behavior of the show command.
When the argument is a keyword, i.e. text with no "/" in it, it simply tries
to find a single matching password and shows it. It only works if the search
matches a single result.
The normal "show" behaviour is not changed if a path is given as an argument.
There is no need to use an extra option or parameter to trigger the
new functionality.

Examples:

Normal show behavior:
$ pass show private/misc/www.example.com
blabla
login: blibli

Keyword based show behavior:
$ pass show example
blabla
login: blibli

$ pass show example.net
Error: example.net is not in the password store.

This patch is formatted against version 1.6.5.

Regards,
William
--- /usr/bin/pass	2015-02-02 19:53:59.983451348 +0100
+++ /usr/bin/pass_	2015-02-02 19:38:34.680459331 +0100
@@ -307,6 +307,13 @@
 	local path="$1"
 	local passfile="$PREFIX/$path.gpg"
 	check_sneaky_paths "$path"
+
+	if echo $path | grep -vq "/"
+	then
+		local lines=$(find "$PREFIX" -type f -iname "*${path}*.gpg")
+		[[ $(echo $lines | wc -l) -eq 1 ]] && passfile=$lines
+	fi
+
 	if [[ -f $passfile ]]; then
 		if [[ $clip -eq 0 ]]; then
 			$GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $?
_______________________________________________
Password-Store mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to