Created
June 10, 2010 14:34
-
-
Save zellyn/433077 to your computer and use it in GitHub Desktop.
Read environment vars into emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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