-
-
Save spacebat/cb601a06f75966438bea to your computer and use it in GitHub Desktop.
This file contains 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
(defun source-env-get (script &rest vars) | |
"Source script in shell, then look for vars in the resulting subshell environment" | |
(loop for line in (split-string (shell-command-to-string (concat "source " script " && set")) "[\n]" t) | |
with result | |
if (string-match "^\\([[:alpha:]]+\\)=\\(.*\\)$" line) | |
do (let ((var (match-string 1 line)) | |
(val (match-string 2 line))) | |
(when (or (not vars) (member var vars)) | |
(push (cons var val) result))) | |
finally return result)) | |
(defun env-set-alist (alist) | |
"Take an alist of string pairs, call setenv with them and return a list of strings by way of logging" | |
(loop for (var . val) in alist | |
do (setenv var val) | |
collect (concat var " = " val))) | |
(unless (getenv "TERM_PROGRAM") | |
(env-set-alist (source-env-get "~/.bash_profile" "PATH" "RIOT_GAMES_API_KEY" "RIOT_GAMES_NEW_KEY"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment