summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-23 07:37:07 +0300
committerThomas Voss <mail@thomasvoss.com> 2023-08-23 07:37:07 +0300
commitf9c216d213ecbffe2e0d50a02ea53c4df2290ee7 (patch)
tree8d22a32f46e2589c9f4c6d5219c8ded5334803d0
parent9605dcab1b76ebb25755d3bbbd7e08f2d4aa4711 (diff)
vlt: Add ‘vlt’ for password management
-rwxr-xr-x.local/bin/vlt21
1 files changed, 21 insertions, 0 deletions
diff --git a/.local/bin/vlt b/.local/bin/vlt
new file mode 100755
index 0000000..5ef64ce
--- /dev/null
+++ b/.local/bin/vlt
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+[ $# -ne 0 ] && {
+ echo "Usage: ${0##*/}" >&2
+ exit 1
+}
+
+: ${vault:="${XDG_DATA_HOME:-$HOME/.local/share}/vault"}
+[ -d "$vault" ] || mkdir -p "$vault"
+cd "$vault"
+
+# We use ‘*’ instead of ‘.’ to avoid the leading ‘./’
+choice="`find * -type f | osel`"
+password="`enchive extract "$choice" /dev/stdout`"
+[ -n "$password" ] \
+ && { printf '%s' "$password" | wl-copy -no; } \
+ && notify-send -a "${0##*/}" -u normal \
+ 'Password copied to the clipboard' \
+ "The password for ‘$choice’ was copied to the clipboard."