Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Created April 18, 2022 17:34
Show Gist options
  • Save twopoint718/bdf8dbcf13b0d15235e42a41582ef4cb to your computer and use it in GitHub Desktop.
Save twopoint718/bdf8dbcf13b0d15235e42a41582ef4cb to your computer and use it in GitHub Desktop.
A bunch of Emacs Lisp utilities.
(defun cjw-load-env-from-file (filename)
"Open a file of environment variable definitions like:
export FOO=bar
export BAZ=quux
and load them into the current environment using `setenv`"
(with-temp-buffer
(insert-file-contents filename)
(goto-char (point-min))
(while (re-search-forward "^export \\(.*\\)=\\(.*\\)$")
(apply 'setenv (list (match-string 1) (match-string 2))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment