Update
This commit is contained in:
@@ -11,7 +11,21 @@
|
|||||||
|
|
||||||
(defconst my-env-file (concat my-local-dir "env"))
|
(defconst my-env-file (concat my-local-dir "env"))
|
||||||
|
|
||||||
(defun my-load-envvars-file (file &optional noerror)
|
(defun my/generate-envvars-file ()
|
||||||
|
"Generate environment variables file at ~/.emacs.d/.local/env."
|
||||||
|
(interactive)
|
||||||
|
;; Ensure the directory exists
|
||||||
|
(unless (file-exists-p my-local-dir)
|
||||||
|
(make-directory my-local-dir t))
|
||||||
|
|
||||||
|
;; Run printenv and redirect output to the env file
|
||||||
|
(with-temp-buffer
|
||||||
|
(call-process "printenv" nil t nil)
|
||||||
|
(write-region (point-min) (point-max) my-env-file nil 'silent))
|
||||||
|
|
||||||
|
(message "Environment variables saved to %s" my-env-file))
|
||||||
|
|
||||||
|
(defun my/load-envvars-file (file &optional noerror)
|
||||||
"Read and set envvars from FILE.
|
"Read and set envvars from FILE.
|
||||||
If NOERROR is non-nil, don't throw an error if the file doesn't exist or is
|
If NOERROR is non-nil, don't throw an error if the file doesn't exist or is
|
||||||
unreadable. Returns the names of envvars that were changed."
|
unreadable. Returns the names of envvars that were changed."
|
||||||
|
|||||||
Reference in New Issue
Block a user