From f3e21ba9cdaec50f2a99f8d33e68204c694c7ac7 Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Fri, 22 May 2026 15:54:20 -0400 Subject: fix some stuff --- kasi.el | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/kasi.el b/kasi.el index 7247a27..f2ca588 100644 --- a/kasi.el +++ b/kasi.el @@ -36,14 +36,24 @@ :type '(string) :group 'kasi) +;;;###autoload +(defcustom kasi-extension ".age" + "Default file extension for creating kasi secrets." + :type '(string) + :group 'kasi) + (defvar kasi-version "1.0") +(defun kasi-filename-short (file) + "Returns shortened name of filename." + (file-name-sans-extension + (file-relative-name file kasi-dir))) + (defun kasi-filename () - "Returns full filename of the secret file." + "Returns full filename of the secret file." (let* ((filenames (file-expand-wildcards (format "%s/*/*" kasi-dir))) (options (mapcar (lambda (f) - (file-name-sans-extension - (file-relative-name f kasi-dir))) + (kasi-filename-short f)) filenames)) (selected (completing-read "File: " options)) (file (elt filenames (seq-position options selected)))) @@ -57,18 +67,22 @@ (defun kasi-totp (file) "Returns current TOTP code from secret file." - (let ((totp-code (kasi-get file 'totp))) + (let* ((totp-secret (kasi-get file 'totp)) + (totp-code (totp (base32-hex-decode totp-secret)))) (kill-new totp-code) - (message "TOTP copied to kill ring"))) + (message (format "TOTP %s for %s copied to kill ring" + totp-code + (kasi-filename-short file))))) ;;;###autoload (defun kasi (command file) "Invoke the kasi secret manager." - (interactive (list (intern (completing-read "Command: " '(edit - password - username - email - totp))) + (interactive (list (intern (completing-read "Command: " + '(edit + password + username + email + totp))) (kasi-filename))) (pcase command ('edit (find-file-other-window file)) @@ -76,6 +90,8 @@ ((or 'password 'username 'email) (progn (kill-new (kasi-get file command)) - (message (format "Copied %s to kill ring." command)))))) + (message (format "Copied %s for %s to kill ring." + command + (kasi-filename-short file))))))) (provide 'kasi) -- cgit v1.2.3