summaryrefslogtreecommitdiff
path: root/lisp/jakob.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/jakob.el')
-rw-r--r--lisp/jakob.el81
1 files changed, 81 insertions, 0 deletions
diff --git a/lisp/jakob.el b/lisp/jakob.el
new file mode 100644
index 0000000..f720d7e
--- /dev/null
+++ b/lisp/jakob.el
@@ -0,0 +1,81 @@
+;;; jakob.el -*- lexical-binding: t; -*-
+;;;
+;;; Author: Jakob L. Kreuze <zerodaysfordays@sdf.org>
+;;; URL: https://git.sr.ht/~jakob/.emacs.d/
+;;;
+;;; Custom elisp written by yours truly that is independent of any particular
+;;; package.
+;;;
+
+
+;;;
+;;; Configuration.
+;;;
+
+;; Bind some keys for working with this configuration file.
+
+(defun config-goto ()
+ "Switch to a buffer visiting the config file."
+ (interactive)
+ (find-file "~/.emacs.d/init.el"))
+
+(bind-key "C-c e" #'config-goto)
+
+
+;;;
+;;; pass
+;;;
+
+;; TODO: Replace with pass.el?
+
+;; Here's a snippet for interactively pulling a password from password-store, so
+;; I'm not spawning a terminal every time I need to invoke my password manager.
+
+(defvar password-store-directory "~/.password-store"
+ "Directory containing passwords managed by `pass'.")
+
+(defun pass-password-files ()
+ "Returns the paths of every password managed by `pass'."
+ (let ((prefix-length (1+ (length password-store-directory)))
+ (suffix-length (length ".gpg")))
+ (map 'list
+ #'(lambda (path) (cl-subseq path prefix-length (- suffix-length)))
+ (directory-files-recursively password-store-directory ".gpg$"))))
+
+(defun pass ()
+ "Prompt for a password and copy it to the clipboard.
+Passwords are taken from `password-store-directory'."
+ (interactive)
+ (let* ((account (completing-read "Account: " (pass-password-files)))
+ (path (concat password-store-directory "/" account ".gpg")))
+ (with-temp-buffer
+ (insert-file-contents path)
+ (clipboard-kill-ring-save 1 (1- (buffer-end 1))))
+ (message "Password for %s copied to clipboard." account)))
+
+
+;;;
+;;; 8-ball
+;;;
+
+;; A little snippet for getting an answer to a dumb question. Responses were
+;; lifted from Wikipedia's page [1] about the toy.
+;;
+;; [1]: https://en.wikipedia.org/wiki/Magic_8-Ball
+
+(defun consult ()
+ "Consult the magic 8-ball.
+Interactive function to consult the magic 8-ball for answers to
+very important questions."
+ (interactive)
+ (let ((responses (list "It is certain." "It is decidedly so."
+ "Without a doubt." "Yes - definitely."
+ "You may rely on it." "As I see it, yes."
+ "Most likely." "Outlook good." "Yes."
+ "Signs point to yes." "Reply hazy, try again."
+ "Ask again later." "Better not tell you now."
+ "Cannot predict now." "Concentrate and ask again."
+ "Don't count on it." "My reply is no."
+ "My sources say no." "Outlook not so good."
+ "Very doubtful.")))
+ (message (elt responses (mod (random) (length responses))))))

© 2015 - 2026 Jakob L. Kreuze