commit 4ae6441547afd94eb8826cb2b4f13bc569dd9d56
parent fad20e27b359f216405aad0e0f0cb7d329bc4817
Author: Vineet Kumar <git@vineetk.net>
Date: Fri, 22 May 2026 18:33:07 -0400
add kasi-get wrapper around kasi--get for use outside emacs
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/README.org b/README.org
@@ -33,6 +33,18 @@ the following format:
(extra-notes "other stuff to encrypt"))
#+end_src
+** Accessing From Other Programs
+To parse and read the values of the secret files (like ='password= or
+='username=), you can run something similar to the following command:
+#+begin_src shell
+ emacsclient -e "(kasi-get \"category/file\" 'password)" | sed 's/^"//; s/"$//'
+#+end_src
+Unfortunately, I was not able to find a way to make =emacsclient=
+print without the return value's type (i.e. without double quotes),
+which does make this more clunky for outside Emacs. +Obviously the
+solution to this is to just remove them and rewrite those programs in
+Emacs Lisp.+
+
** Never Asked Questions (NAQ)
*** Why should I use this over any other password manager?
Don't. For a serious answer, it's because this uses S-expressions for
diff --git a/kasi.el b/kasi.el
@@ -77,6 +77,10 @@ Two %s are needed for password and username for now.")
(insert-file-contents file)
(alist-get elem (read (current-buffer))))))
+(defun kasi-get (file elem)
+ "Prints decrypted element. Wrapper around kasi--get for non-Emacs use."
+ (kasi--get (format "%s/%s%s" kasi-dir file kasi-extension) elem))
+
(defun kasi--totp (file)
"Returns current TOTP code from secret file."
(let* ((totp-secret (kasi--get file 'totp))