From 1d1de0dd6ab81c17667b43c4a7900efa3c262c0f Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Fri, 22 May 2026 14:40:59 -0400 Subject: initial payload --- .gitignore | 1 + kasi.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 kasi.el diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1fd86f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +#* diff --git a/kasi.el b/kasi.el new file mode 100644 index 0000000..309f442 --- /dev/null +++ b/kasi.el @@ -0,0 +1,44 @@ +(defcustom kasi-dir "/data/kasi" + "Default base directory for kasi-related functions." + :type '(string) + :group 'kasi) + +(defun kasi-filename () + "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))) + filenames)) + (selected (completing-read "File: " options)) + (file (elt filenames (seq-position options selected)))) + file)) + +(defun kasi-get (file elem) + "Returns element from secret file." + (car (with-temp-buffer + (insert-file-contents file) + (alist-get elem (read (current-buffer)))))) + +(defun kasi (command file) + "Invoke the kasi secret manager." + (interactive (list (intern (completing-read "Command: " '(edit + password + username + email + totp))) + (kasi-filename))) + (pcase command + ('edit (find-file-other-window file)) + ('totp (kasi-totp file)) + ((or 'password 'username 'email) + (progn + (kill-new (kasi-get file command)) + (message (format "Copied %s to kill ring." command)))))) + +(defun kasi-totp (file) + "Returns current TOTP code from secret file." + (interactive (list (kasi-filename))) + (let ((totp (kasi-get file 'totp))) + (kill-new totp) + (message "TOTP copied to kill ring"))) -- cgit v1.2.3