spm

Personal fork of spm (simple password manager)

commit 9753c46a2f94c25f6fafb84bd6f943c004bab2b8
parent eb588fdbd0daadd6528c9f107062ff54f7795b4c
Author: nmeum <git-nmeum@8pit.net>
Date: Tue, 25 Mar 2014 10:51:07 +0100

Ignore .git in storage directory and improve find command

It would probably be better if tpm ignores ~/.password-store/.* since
other people might have other hidden files in this directory.
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/bash_completion b/bash_completion
@@ -3,9 +3,9 @@ _tpm() {
 	local cmd="${COMP_WORDS[1]}"
 
 	if [[ "${cmd}" = "insert" ]]; then
-		_tpm_complete_entries -true
+		_tpm_complete_entries
 	elif [[ "${cmd}" = "show" ]]; then
-		_tpm_complete_entries -iname '*.gpg' -type f
+		_tpm_complete_entries -type f
 	else
 		COMPREPLY=($(compgen -W "insert show" -- ${cur}))
 	fi

@@ -15,7 +15,7 @@ _tpm_complete_entries() {
 	local dir="${TPM_STORE_DIR:-${HOME}/.password-store}"
 
 	if [[ -d "${dir}" ]]; then
-		local files="$(find "${dir}/" $@ -print | sed -e "s^${dir}.^^" -e 's^\.gpg^^' | sort)"
+		local files="$(find -L "${dir}/" -name '.git' -prune -o $@ -print | sed -e "s|${dir}.||" -e "s|\.gpg||" | sort)"
 		COMPREPLY=($(compgen -W "${files}" -- ${cur}))
 	fi
 }
diff --git a/zsh_completion b/zsh_completion
@@ -3,9 +3,9 @@
 _tpm() {
   local cmd=${words[2]}
   if [[ "${cmd}" = "insert" ]]; then
-    _tpm_complete_entries -true
+    _tpm_complete_entries
   elif [[ "${cmd}" = "show" ]]; then
-    _tpm_complete_entries -iname '*.gpg' -type f
+    _tpm_complete_entries -type f
   else
     local -a subcommands
     subcommands=(

@@ -21,6 +21,6 @@ _tpm_complete_entries() {
   local dir="${TPM_STORE_DIR:-${HOME}/.password-store}"
 
   if [[ -d "${dir}" ]]; then
-  	_values -C 'entries' $(find "${dir}/" $@ -print | sed -e "s^${dir}.^^" -e 's^\.gpg^^' | sort)
+	_values -C 'entries' $(find -L "${dir}/" -name '.git' -prune -o $@ -print | sed -e "s|${dir}.||" -e "s|\.gpg||" | sort)
   fi
 }