aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
l---------.local/share/pass-extensions/dir.bash1
-rwxr-xr-x.local/share/pass-extensions/directory.bash12
-rwxr-xr-x.local/share/pass-extensions/duplicates.bash20
-rwxr-xr-x.local/share/pass-extensions/names.bash17
4 files changed, 41 insertions, 9 deletions
diff --git a/.local/share/pass-extensions/dir.bash b/.local/share/pass-extensions/dir.bash
new file mode 120000
index 0000000..395da23
--- /dev/null
+++ b/.local/share/pass-extensions/dir.bash
@@ -0,0 +1 @@
+directory.bash \ No newline at end of file
diff --git a/.local/share/pass-extensions/directory.bash b/.local/share/pass-extensions/directory.bash
new file mode 100755
index 0000000..84db500
--- /dev/null
+++ b/.local/share/pass-extensions/directory.bash
@@ -0,0 +1,12 @@
+#!/bin/bash
+# print the initialized password store directory as a fully qualified path.
+# exits with code 1 if the password store is not initialized.
+dir="${PASSWORD_STORE_DIR-$HOME/.password-store}"
+dir="$(realpath "$dir")"
+if [ -e "$dir/.gpg-id" ] ; then
+ echo "$dir"
+else
+ echo "error: password store is not initialized" >&2
+ exit 1
+fi
+
diff --git a/.local/share/pass-extensions/duplicates.bash b/.local/share/pass-extensions/duplicates.bash
index 57fdbe0..b7e57a4 100755
--- a/.local/share/pass-extensions/duplicates.bash
+++ b/.local/share/pass-extensions/duplicates.bash
@@ -1,11 +1,8 @@
#!/bin/bash
-cd "${PASSWORD_STORE_DIR-$HOME/.password-store}" || exit 1
-
declare -A dupe_tally dupe_map
-pass_names="$(\
- find . -type d -name '.git' -prune -o -name '*.gpg' -type f -print |\
- cut -c3- | rev | cut -c5- | rev)"
+pass_names="$(pass names)"
+[ $? -ne 0 ] && exit 1
pass_count="$(echo "$pass_names" | wc -l)"
if [ "$pass_count" -gt 10 ] ; then
@@ -24,23 +21,28 @@ while read pass_name ; do
dupe_tally["$hash"]=$(( ${dupe_tally["$hash"]} + 1 ))
done < <(echo "$pass_names")
-duplicates=0
+unique_duplicates=0
+total_shared=0
for talley_key in "${!dupe_tally[@]}" ; do
[ "${dupe_tally["$talley_key"]}" -le 1 ] && continue;
- duplicates=$(( $duplicates + 1 ))
+ unique_duplicates=$(( $unique_duplicates + 1 ))
echo "same password:"
for pass_name in "${!dupe_map[@]}" ; do
[ "${dupe_map["$pass_name"]}" != "$talley_key" ] && continue;
echo "- $pass_name"
+ total_shared=$(( $total_shared + 1 ))
done
echo
done
echo "summary:"
-if [ $duplicates -eq 0 ] ; then
+if [ $unique_duplicates -eq 0 ] ; then
echo "- no duplicates"
else
- echo "- found $duplicates password(s) that were used more than once"
+ cat << EOF
+- found $unique_duplicates password(s) that were used more than once
+- you should change all $total_shared passwords listed above
+EOF
fi
diff --git a/.local/share/pass-extensions/names.bash b/.local/share/pass-extensions/names.bash
new file mode 100755
index 0000000..4ef474a
--- /dev/null
+++ b/.local/share/pass-extensions/names.bash
@@ -0,0 +1,17 @@
+#!/bin/bash
+# list all passwords in store
+
+pass_dir="$(pass directory)"
+[ $? -ne 0 ] && exit 1
+cd "$pass_dir"
+
+# List all files in password store (ignoring .git and .extensions folders) and
+# trim './' prefix and '.gpg' suffix
+find . \
+ -type d -name '.git' -prune \
+ -o -type d -name '.extensions' -prune \
+ -o -name '*.gpg' \
+ -type f \
+ -print |\
+cut -c3- | rev | cut -c5- | rev
+