Hi,

I really love pass and I wanted to extend it by passing it's output to fzf(https://github.com/junegunn/fzf) to easilly search through available entries. Unfortunately the current output format makes it impossible to easilly use it for fzf.

So I propose the following patch to add an -f,--full(same as for tree) options to print out the list with full paths.

This way one can easily use pass and fzf in following way:

pass -f | fzf | xargs -I{} pass -- {}

Which in a trivial way gives a fuzzy search ability to pass.

I'm not sure if this approach is the best but I've used it successfully for a while now. I think it could be useful to more people.

Cheers!
diff --git a/src/password-store.sh b/src/password-store.sh
index d535a74..5d9cd99 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -223,7 +223,7 @@ cmd_usage() {
 	        List passwords.
 	    $PROGRAM find pass-names...
 	    	List passwords that match pass-names.
-	    $PROGRAM [show] [--clip,-c] pass-name
+	    $PROGRAM [show] [--full,-f] [--clip,-c] pass-name
 	        Show existing password and optionally put it on the clipboard.
 	        If put on the clipboard, it will be cleared in $CLIP_TIME seconds.
 	    $PROGRAM grep search-string
@@ -295,15 +295,16 @@ cmd_init() {
 
 cmd_show() {
 	local opts clip=0
-	opts="$($GETOPT -o c -l clip -n "$PROGRAM" -- "$@")"
+	opts="$($GETOPT -o cf -l clip,full -n "$PROGRAM" -- "$@")"
 	local err=$?
 	eval set -- "$opts"
 	while true; do case $1 in
 		-c|--clip) clip=1; shift ;;
+		-f|--full) full=1; shift ;;
 		--) shift; break ;;
 	esac done
 
-	[[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip,-c] [pass-name]"
+	[[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--full,-f] [--clip,-c] [pass-name]"
 
 	local path="$1"
 	local passfile="$PREFIX/$path.gpg"
@@ -322,7 +323,12 @@ cmd_show() {
 		else
 			echo "${path%\/}"
 		fi
-		tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
+        if [[ $full ]]; then
+		    TREE=$(tree -i -f --noreport "$PREFIX/$path" | sed "s#${PREFIX}/##" | grep '/')
+        else
+		    TREE=$(tree -C -l --noreport "$PREFIX/$path")
+        fi
+        echo "$TREE" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
 	elif [[ -z $path ]]; then
 		die "Error: password store is empty. Try \"pass init\"."
 	else
_______________________________________________
Password-Store mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to