Add -o option to 'doom env'
Now you can output envvar files where ever you like.
This commit is contained in:
parent
9f08d11908
commit
f6b8807e83
2 changed files with 90 additions and 87 deletions
3
bin/doom
3
bin/doom
|
@ -98,7 +98,6 @@
|
||||||
(print! (error "No command detected.\n")))
|
(print! (error "No command detected.\n")))
|
||||||
(usage))
|
(usage))
|
||||||
((require 'core-cli)
|
((require 'core-cli)
|
||||||
(let ((default-directory user-emacs-directory))
|
|
||||||
(setq argv nil)
|
(setq argv nil)
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(doom-dispatch (car args) (cdr args))
|
(doom-dispatch (car args) (cdr args))
|
||||||
|
@ -119,4 +118,4 @@
|
||||||
"Emacs outputs to standard error, so you'll need to redirect stderr to\n"
|
"Emacs outputs to standard error, so you'll need to redirect stderr to\n"
|
||||||
"stdout to pipe this to a file or clipboard!\n\n"
|
"stdout to pipe this to a file or clipboard!\n\n"
|
||||||
" e.g. doom -d install 2>&1 | clipboard-program"))
|
" e.g. doom -d install 2>&1 | clipboard-program"))
|
||||||
(signal 'doom-error e)))))))))
|
(signal 'doom-error e))))))))
|
||||||
|
|
|
@ -22,22 +22,24 @@ This file is automatically regenerated when you run this command or 'doom
|
||||||
refresh'. However, 'doom refresh' will only regenerate this file if it exists.
|
refresh'. However, 'doom refresh' will only regenerate this file if it exists.
|
||||||
|
|
||||||
Use the -c or --clear switch to delete your envvar file."
|
Use the -c or --clear switch to delete your envvar file."
|
||||||
(let ((default-directory doom-emacs-dir))
|
|
||||||
(when (member "clear" args) ; DEPRECATED
|
(when (member "clear" args) ; DEPRECATED
|
||||||
(message "'doom env clear' is deprecated. Use 'doom env -c' or 'doom env --clear' instead")
|
(message "'doom env clear' is deprecated. Use 'doom env -c' or 'doom env --clear' instead")
|
||||||
(push "-c" args))
|
(push "-c" args))
|
||||||
|
|
||||||
|
(let ((env-file (or (cadr (member "-o" args))
|
||||||
|
doom-env-file)))
|
||||||
(cond ((or (member "-c" args)
|
(cond ((or (member "-c" args)
|
||||||
(member "--clear" args))
|
(member "--clear" args))
|
||||||
(unless (file-exists-p doom-env-file)
|
(unless (file-exists-p env-file)
|
||||||
(user-error! "%S does not exist to be cleared"
|
(user-error! "%S does not exist to be cleared"
|
||||||
(relpath doom-env-file)))
|
(relpath env-file)))
|
||||||
(delete-file doom-env-file)
|
(delete-file env-file)
|
||||||
(print! (success "Successfully deleted %S")
|
(print! (success "Successfully deleted %S")
|
||||||
(relpath doom-env-file)))
|
(relpath env-file)))
|
||||||
|
|
||||||
((null args)
|
((or (null args)
|
||||||
(doom-reload-env-file 'force))
|
(member "-o" args))
|
||||||
|
(doom-reload-env-file 'force env-file))
|
||||||
|
|
||||||
((user-error "I don't understand 'doom env %s'"
|
((user-error "I don't understand 'doom env %s'"
|
||||||
(string-join args " "))))))
|
(string-join args " "))))))
|
||||||
|
@ -79,21 +81,23 @@ It is rare that you'll need to change this.")
|
||||||
This is a list of strings. Each entry is run separately and in sequence with
|
This is a list of strings. Each entry is run separately and in sequence with
|
||||||
`doom-env-executable' to scrape envvars from your shell environment.")
|
`doom-env-executable' to scrape envvars from your shell environment.")
|
||||||
|
|
||||||
;; Borrows heavily from Spacemacs' `spacemacs//init-spacemacs-env'.
|
(defun doom-reload-env-file (&optional force-p env-file)
|
||||||
(defun doom-reload-env-file (&optional force-p)
|
|
||||||
"Generates `doom-env-file', if it doesn't exist (or if FORCE-P).
|
"Generates `doom-env-file', if it doesn't exist (or if FORCE-P).
|
||||||
|
|
||||||
This scrapes the variables from your shell environment by running
|
This scrapes the variables from your shell environment by running
|
||||||
`doom-env-executable' through `shell-file-name' with `doom-env-switches'. By
|
`doom-env-executable' through `shell-file-name' with `doom-env-switches'. By
|
||||||
default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
||||||
`doom-env-ignored-vars' are removed."
|
`doom-env-ignored-vars' are removed."
|
||||||
(when (or force-p (not (file-exists-p doom-env-file)))
|
(let ((env-file (if env-file
|
||||||
(with-temp-file doom-env-file
|
(expand-file-name env-file)
|
||||||
|
doom-env-file)))
|
||||||
|
(when (or force-p (not (file-exists-p env-file)))
|
||||||
|
(with-temp-file env-file
|
||||||
(print! (start "%s envvars file at %S")
|
(print! (start "%s envvars file at %S")
|
||||||
(if (file-exists-p doom-env-file)
|
(if (file-exists-p env-file)
|
||||||
"Regenerating"
|
"Regenerating"
|
||||||
"Generating")
|
"Generating")
|
||||||
(relpath doom-env-file doom-emacs-dir))
|
(relpath env-file doom-emacs-dir))
|
||||||
(let ((process-environment doom--initial-process-environment))
|
(let ((process-environment doom--initial-process-environment))
|
||||||
(let ((shell-command-switch doom-env-switches)
|
(let ((shell-command-switch doom-env-switches)
|
||||||
(error-buffer (get-buffer-create "*env errors*")))
|
(error-buffer (get-buffer-create "*env errors*")))
|
||||||
|
@ -138,5 +142,5 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
||||||
(print! (info "Ignoring %s") var)
|
(print! (info "Ignoring %s") var)
|
||||||
(delete-region (match-beginning 0) (1- valend)))))))
|
(delete-region (match-beginning 0) (1- valend)))))))
|
||||||
(print! (success "Successfully generated %S")
|
(print! (success "Successfully generated %S")
|
||||||
(relpath doom-env-file doom-emacs-dir))
|
(relpath env-file doom-emacs-dir))
|
||||||
t)))))
|
t))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue