commit: fa1cd65ba5ee6c0e3575e81610cf170cc403ad83
parent 80525c39658687f356c6e940124a393c0388dd36
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 14 Aug 2022 04:47:04 +0200
secret: Add delete command
Diffstat:
M | secret | 21 | +++++++++++++++++++++ |
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/secret b/secret
@@ -75,6 +75,24 @@ secret_edit() {
secret_write "$@" < "$file" ; rm -f "$file"
}
+secret_delete() {
+ entry="$*"
+
+ (
+ cd "${basepath}"
+
+ if test -f "${basepath}/.git/HEAD"
+ then
+ git rm "${entry}.reop"
+ git commit -m "${entry}: remove"
+ if [ "$(git remote show -n)" != "" ]; then git push; fi
+ else
+ echo "No git repository in ‘$basepath’, consider creating one"
+ rm "${entry}.reop"
+ fi
+ )
+}
+
secret_dmenu() {
echo | dmenu -nb '#000' -nf '#000' -p "Passphrase: "
}
@@ -116,6 +134,8 @@ secret write <entry>
Write a secret entry.
secret edit <entry>
Wrapper around $EDITOR for easy secret edition.
+secret delete <entry>
+ Delete a secret entry.
secret dmenu
dmenu on entries, dmenu for a passphrase, read secret, pipe to xclip(1).
@@ -141,6 +161,7 @@ case "$command" in
read) secret_read "$@" ;;
write) secret_write "$@" ;;
edit) secret_edit "$@" ;;
+ del*) secret_delete "$@" ;;
dmenu) secret_dmenu_read "$@" ;;
ls-oath) secret_list_oath "$@" ;;