Skip to content

Instantly share code, notes, and snippets.

@zellyn
Created June 10, 2010 14:34
Show Gist options
  • Save zellyn/433077 to your computer and use it in GitHub Desktop.
Save zellyn/433077 to your computer and use it in GitHub Desktop.
Read environment vars into emacs
(let* ((env-output (shell-command-to-string "source .bashrc ; source .emacs.d/emacsenv.sh"))
(lines (split-string env-output "[\r\n]+" t))
(regex "^\\([^ ]+\\) \\(.*\\)$")
(pairs (mapcar (lambda (line)
(if (string-match regex line)
(list (match-string 1 line) (match-string 2 line))))
lines)))
(mapc (lambda (pair) (apply 'setenv pair)) pairs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment