aboutsummaryrefslogtreecommitdiff
path: root/.local/share/pass-extensions
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-03-05 17:47:41 +0100
committerlonkaars <loek@pipeframe.xyz>2024-03-05 17:47:41 +0100
commit638a714138c61a05bce07af79612edc21a0c7f59 (patch)
tree2abbcddc5ec30afe01fafb0a051bee2146c61554 /.local/share/pass-extensions
parent2abd0e0218ba60e9f0dad348a3c2243a3324e40c (diff)
more pass extensions + remove fehbg from bgcol script
Diffstat (limited to '.local/share/pass-extensions')
-rwxr-xr-x.local/share/pass-extensions/exit.bash2
-rwxr-xr-x.local/share/pass-extensions/names.bash2
-rwxr-xr-x.local/share/pass-extensions/treasure.bash47
3 files changed, 50 insertions, 1 deletions
diff --git a/.local/share/pass-extensions/exit.bash b/.local/share/pass-extensions/exit.bash
new file mode 100755
index 0000000..06bd986
--- /dev/null
+++ b/.local/share/pass-extensions/exit.bash
@@ -0,0 +1,2 @@
+#!/bin/bash
+exit 0
diff --git a/.local/share/pass-extensions/names.bash b/.local/share/pass-extensions/names.bash
index 4ef474a..e96548f 100755
--- a/.local/share/pass-extensions/names.bash
+++ b/.local/share/pass-extensions/names.bash
@@ -7,7 +7,7 @@ cd "$pass_dir"
# List all files in password store (ignoring .git and .extensions folders) and
# trim './' prefix and '.gpg' suffix
-find . \
+find -L . \
-type d -name '.git' -prune \
-o -type d -name '.extensions' -prune \
-o -name '*.gpg' \
diff --git a/.local/share/pass-extensions/treasure.bash b/.local/share/pass-extensions/treasure.bash
new file mode 100755
index 0000000..e79ec24
--- /dev/null
+++ b/.local/share/pass-extensions/treasure.bash
@@ -0,0 +1,47 @@
+#!/bin/bash
+TAB="$(printf '\t')"
+
+# TODO: add options:
+# --help to display some help
+# --list to list all the versions of a password
+
+# print error if fzf is not found
+command -v fzf > /dev/null || exec bash -c fzf || exit 1
+
+# load pass source code for accessing internals
+exit() { true ; } # disable exit command
+. "$(command -v pass)" exit # source pass source (bash)
+exit() { command exit ; } # restore exit command
+
+cd "$(pass directory)"
+
+set_git "$PWD/"
+if [ -z "$INNER_GIT_DIR" ] ; then
+ cat << "EOF" >&2
+pass-treasure only works when the password store is tracked under version
+control using git!
+EOF
+fi
+
+# create a list of all files that ever existed in the password store
+# repository, then filter empty lines (created by git log), only show file
+# names ending in .gpg, and sort the list
+repo_files_all="$(\
+ cmd_git log --all --pretty="format:" --name-only --diff-filter=A |\
+ sed '/^$/d' | sed -n '/\.gpg$/p' |\
+ sort)"
+
+IFS="$TAB" read -r date file hash < <(
+ while read -u 3 -r file ; do
+ while IFS="$TAB" read -u 4 -r hash date ; do
+ printf '%s\t%s\t%s\n' "$date" "$file" "$hash"
+ done 4< <(
+ cmd_git log --no-patch --diff-filter=ABCMRTUX --format="format:%H$TAB%ad" \
+ -- "$file"
+ echo
+ )
+ done 3< <( echo "$repo_files_all" ) | fzf --tabstop=4
+)
+
+cmd_git cat-file -p "$hash:$file" | $GPG -d "${GPG_OPTS[@]}" -
+