Merge branch 'master' of git.jeremydormitzer.com:jdormit/dotfiles
This commit is contained in:
commit
3ddc4ed4f7
192
emacs/init.org
192
emacs/init.org
@ -8,6 +8,11 @@ It's meant to be loaded from init.el like so:
|
||||
(org-babel-load-file (expand-file-name "path/to/init.org"))
|
||||
#+END_SRC
|
||||
|
||||
* File Variables
|
||||
Enables lexical binding for everything in init.el:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
;;; -*- lexical-binding: t; -*-
|
||||
#+END_SRC
|
||||
* Default directory
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cd "~")
|
||||
@ -152,11 +157,6 @@ Requires:
|
||||
(eval-when-compile (require 'subr-x))
|
||||
#+END_SRC
|
||||
|
||||
Default to lexical binding:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq lexical-binding t)
|
||||
#+END_SRC
|
||||
|
||||
** Load path
|
||||
For machine or user specific libraries:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
@ -201,14 +201,14 @@ Format a millis timestamp into human-readable form:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun format-epoch-millis (millis)
|
||||
(interactive "nTimestamp: ")
|
||||
(message (format-time-string "%x %X" (/ millis 1000))))
|
||||
(message (format-time-string "%F %r" (/ millis 1000))))
|
||||
#+END_SRC
|
||||
|
||||
The same but for seconds:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun format-epoch-seconds (seconds)
|
||||
(interactive "nTimestamp: ")
|
||||
(message (format-time-string "%x %X" seconds)))
|
||||
(message (format-time-string "%F %r" seconds)))
|
||||
#+END_SRC
|
||||
|
||||
** Persisting variables between session
|
||||
@ -1002,6 +1002,8 @@ Emacs support for the Language Server Protocol
|
||||
(use-package dap-mode
|
||||
:after (lsp-mode))
|
||||
|
||||
(add-to-list 'evil-emacs-state-modes 'xref--xref-buffer-mode)
|
||||
|
||||
(with-eval-after-load 'lsp-clients
|
||||
(defun lsp-typescript-javascript-tsx-jsx-activate-p (filename major-mode)
|
||||
"Checks if the javascript-typescript language server should be enabled
|
||||
@ -2576,101 +2578,106 @@ GraphQL environments:
|
||||
(local . ("http://localhost:7200/api/graphql" .
|
||||
,(password-store-get "lola-graphql-local-token")))))
|
||||
#+END_SRC
|
||||
* Lola
|
||||
Some functions to make my day job easier. I need to clean these up and put a nice abstraction over them. It goes something like:
|
||||
1. Define the buffer name and the working directory
|
||||
2. Kill and re-create the buffer if it exists, then switch to it
|
||||
3. Run some setup functions
|
||||
4. Enter eshell mode and run a command
|
||||
5. profit
|
||||
|
||||
* Kubernetes
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun lola-server ()
|
||||
(interactive)
|
||||
(if-let ((buf (get-buffer "*lola-server*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-server*")))
|
||||
(use-package kubernetes
|
||||
:ensure t
|
||||
:commands (kubernetes-overview)
|
||||
:config (leader-def-key "ak" #'kubernetes-overview))
|
||||
|
||||
;; If you want to pull in the Evil compatibility package.
|
||||
(use-package kubernetes-evil
|
||||
:ensure t
|
||||
:after kubernetes)
|
||||
#+END_SRC
|
||||
|
||||
* Lola
|
||||
Some functions to make my day job easier.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :lexical yes
|
||||
(defun run-service-in-eshell (name dir cmd &optional setup)
|
||||
(if-let ((buf (get-buffer name)))
|
||||
(progn (when (eq major-mode 'eshell-mode)
|
||||
(eshell-interrupt-process)
|
||||
(while eshell-process-list))
|
||||
(kill-buffer buf)))
|
||||
(let ((buf (get-buffer-create name)))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/lola-server")
|
||||
(cd dir)
|
||||
(eshell-mode)
|
||||
(when setup (funcall setup))
|
||||
(insert cmd)
|
||||
(eshell-send-input)))
|
||||
|
||||
(defun get-python-setup (venv)
|
||||
(lambda ()
|
||||
(eshell/deactivate)
|
||||
(direnv-update-directory-environment (eshell/pwd))
|
||||
(pyvenv-workon "lola-server")
|
||||
(insert "gunicorn -t 120 -c server/web/gunicorn.conf.py bin.start_web:init_and_create_flask_app\\(\\)")
|
||||
(eshell-send-input)))
|
||||
(pyvenv-workon venv)))
|
||||
|
||||
(defun lola-server ()
|
||||
(interactive)
|
||||
(run-service-in-eshell
|
||||
"*lola-server*"
|
||||
"~/lola/lola-server"
|
||||
"gunicorn -t 120 -c server/web/gunicorn.conf.py bin.start_web:init_and_create_flask_app\\(\\)"
|
||||
(get-python-setup "lola-server")))
|
||||
|
||||
(defun lola-celery-worker ()
|
||||
(interactive)
|
||||
(if-let ((buf (get-buffer "*lola-celery-worker*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-celery-worker*")))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/lola-server")
|
||||
(eshell-mode)
|
||||
(eshell/deactivate)
|
||||
(direnv-update-directory-environment (eshell/pwd))
|
||||
(pyvenv-workon "lola-server")
|
||||
(insert "python bin/start_celery_worker.py -P gevent")
|
||||
(eshell-send-input)))
|
||||
(run-service-in-eshell
|
||||
"*lola-celery-worker*"
|
||||
"~/lola/lola-server"
|
||||
"python bin/start_celery_worker.py -P gevent"
|
||||
(get-python-setup "lola-server")))
|
||||
|
||||
(defun lola-travel-service ()
|
||||
(interactive)
|
||||
(if-let ((buf (get-buffer "*lola-travel-service*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-travel-service*")))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/lola-travel-service")
|
||||
(eshell-mode)
|
||||
(eshell/deactivate)
|
||||
(direnv-update-directory-environment (eshell/pwd))
|
||||
(pyvenv-workon "travel-service")
|
||||
(insert "python bin/start_web.py")
|
||||
(eshell-send-input)))
|
||||
(run-service-in-eshell
|
||||
"*lola-travel-service*"
|
||||
"~/lola/lola-travel-service"
|
||||
"python bin/start_web.py"
|
||||
(get-python-setup "travel-service")))
|
||||
|
||||
(defun lola-secrets ()
|
||||
(interactive)
|
||||
(if-let ((buf (get-buffer "*lola-secrets*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-secrets*")))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/secrets")
|
||||
(eshell-mode)
|
||||
(eshell/deactivate)
|
||||
(direnv-update-directory-environment (eshell/pwd))
|
||||
(pyvenv-workon "secrets")
|
||||
(insert "python bin/cmdline.py www")
|
||||
(eshell-send-input)))
|
||||
(run-service-in-eshell
|
||||
"*lola-secrets*"
|
||||
"~/lola/secrets"
|
||||
"python bin/cmdline.py www"
|
||||
(get-python-setup "secrets")))
|
||||
|
||||
(defun lola-desktop (env)
|
||||
(interactive
|
||||
(list (ido-completing-read+
|
||||
"Environment: "
|
||||
'("local" "development" "staging"))))
|
||||
"Environment: "
|
||||
'("local" "development" "staging"))))
|
||||
(run-service-in-eshell
|
||||
"*lola-desktop*"
|
||||
"~/lola/lola-desktop"
|
||||
"npm start"
|
||||
(lambda () (setenv "LOLA_ENV" env))))
|
||||
|
||||
(if-let ((buf (get-buffer "*lola-desktop*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-desktop*")))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/lola-desktop")
|
||||
(eshell-mode)
|
||||
(setenv "LOLA_ENV" env)
|
||||
(insert "npm start")
|
||||
(eshell-send-input)))
|
||||
|
||||
(defun lola-wallet ()
|
||||
(defun lola-wallet (env)
|
||||
(interactive
|
||||
(list (ido-completing-read+
|
||||
"Environment: "
|
||||
'("local" "development" "staging"))))
|
||||
(if-let ((buf (get-buffer "*lola-wallet*")))
|
||||
(kill-buffer buf))
|
||||
(let ((buf (get-buffer-create "*lola-wallet*")))
|
||||
(switch-to-buffer buf)
|
||||
(cd "~/lola/wallet")
|
||||
(eshell-mode)
|
||||
(setenv "LOLA_ENV" "local")
|
||||
(insert "npm start")
|
||||
(eshell-send-input)))
|
||||
"Environment: "
|
||||
'("local" "development" "staging"))))
|
||||
(run-service-in-eshell
|
||||
"*lola-wallet*"
|
||||
"~/lola/wallet"
|
||||
"npm start"
|
||||
(lambda () (setenv "LOLA_ENV" env))))
|
||||
|
||||
(defun lola-run-all ()
|
||||
(interactive)
|
||||
(let ((fns (list #'lola-travel-service
|
||||
#'lola-server
|
||||
#'lola-celery-worker
|
||||
#'lola-desktop
|
||||
#'lola-wallet
|
||||
#'lola-secrets)))
|
||||
(mapcar #'call-interactively fns)))
|
||||
|
||||
(jdormit/define-prefix "L" "lola")
|
||||
(leader-def-key "Ls" #'lola-server)
|
||||
@ -2679,4 +2686,27 @@ Some functions to make my day job easier. I need to clean these up and put a nic
|
||||
(leader-def-key "Ld" #'lola-desktop)
|
||||
(leader-def-key "Lw" #'lola-wallet)
|
||||
(leader-def-key "LS" #'lola-secrets)
|
||||
(leader-def-key "LA" #'lola-run-all)
|
||||
#+END_SRC
|
||||
|
||||
The aws-mfa command:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun aws-mfa-sentinel (proc event)
|
||||
(cond ((string-match-p "finished" event)
|
||||
(progn
|
||||
(message "AWS MFA succeeded")
|
||||
(kill-buffer "*aws-mfa*")))
|
||||
(t
|
||||
(progn
|
||||
(message "AWS MFA failed, check *aws-mfa* buffer for details")))))
|
||||
|
||||
(defun aws-mfa (mfa-token)
|
||||
(interactive "MMFA code: ")
|
||||
(let ((proc (start-process "aws-mfa" "*aws-mfa*" "/Users/jdormit/.virtualenvs/k8s-deploy/bin/aws-mfa" "--force")))
|
||||
(set-process-sentinel proc #'aws-mfa-sentinel)
|
||||
(process-send-string proc (concat mfa-token "\n"))))
|
||||
|
||||
(with-eval-after-load 'kubernetes
|
||||
(general-def 'motion kubernetes-overview-mode-map "m" #'aws-mfa))
|
||||
#+END_SRC
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user