Hello,

I attach diff that adds -1 flag to ls command, which causes pass to
list items one per row, like this:
Business/some-silly-business-site.com
Business/another-business-site.net
Email/donenfeld.com
Email/zx2c4.com
France/bank
France/freebox
France/mobilephone

This make it easier to make completion for csh.
Hope you find it usefull

-- 
// Serpent7776
diff --git a/src/password-store.sh b/src/password-store.sh
index cfc25cc..550a162 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -228,7 +228,7 @@ cmd_usage() {
 	    $PROGRAM init [--path=subfolder,-p subfolder] gpg-id...
 	        Initialize new password storage and use gpg-id for encryption.
 	        Selectively reencrypt existing passwords using new gpg-id.
-	    $PROGRAM [ls] [subfolder]
+	    $PROGRAM [ls] [-1] [subfolder]
 	        List passwords.
 	    $PROGRAM find pass-names...
 	    	List passwords that match pass-names.
@@ -304,16 +304,17 @@ cmd_init() {
 }
 
 cmd_show() {
-	local opts clip=0
-	opts="$($GETOPT -o c -l clip -n "$PROGRAM" -- "$@")"
+	local opts clip=0 one_per_row=0
+	opts="$($GETOPT -o c -l clip -o 1 -n "$PROGRAM" -- "$@")"
 	local err=$?
 	eval set -- "$opts"
 	while true; do case $1 in
 		-c|--clip) clip=1; shift ;;
+		-1) one_per_row=1; shift ;;
 		--) shift; break ;;
 	esac done
 
-	[[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip,-c] [pass-name]"
+	[[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND [--clip,-c,-1] [pass-name]"
 
 	local path="$1"
 	local passfile="$PREFIX/$path.gpg"
@@ -327,12 +328,16 @@ cmd_show() {
 			clip "$pass" "$path"
 		fi
 	elif [[ -d $PREFIX/$path ]]; then
-		if [[ -z $path ]]; then
-			echo "Password Store"
+		if [[ $one_per_row -eq 0 ]]; then
+			if [[ -z $path ]]; then
+				echo "Password Store"
+			else
+				echo "${path%\/}"
+			fi
+			tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//'
 		else
-			echo "${path%\/}"
+			( cd $PREFIX && find ./ -type f -iname \*.gpg | sed -e 's/\.gpg$//' -e 's/\.\///' )
 		fi
-		tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//'
 	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