Add new variable dotspacemacs-import-env-vars-shell-file-name
Used to fetch the environment variables. This allows to keep shell-file-name untouched.
This commit is contained in:
parent
9ee832955a
commit
d28990537f
|
@ -62,6 +62,13 @@ or `spacemacs'.")
|
|||
from your default shell on startup. This is enabled by default for macOS users
|
||||
and X11 users.")
|
||||
|
||||
(defvar dotspacemacs-import-env-vars-shell-file-name nil
|
||||
"If nil then use the default shell is used to fetch the environment variables.
|
||||
Set this variable to a different shell executable path to import the environment
|
||||
variables from this shell. Note that `file-shell-name' is preserved and always
|
||||
points to the default shell. For instance to use your fish shell environment
|
||||
variables set this variable to `/usr/local/bin/fish'.")
|
||||
|
||||
(defvar dotspacemacs-enable-emacs-pdumper nil
|
||||
"If non-nil then enable support for the portable dumper. You'll need
|
||||
to compile Emacs 27 from source following the instructions in file
|
||||
|
|
|
@ -162,6 +162,15 @@ It should only modify the values of Spacemacs settings."
|
|||
(or (eq system-type 'darwin)
|
||||
(eq window-system 'x)))
|
||||
|
||||
;; If nil then use the default shell is used to fetch the environment
|
||||
;; variables. Set this variable to a different shell executable path to
|
||||
;; import the environment variables from this shell. Note that
|
||||
;; `file-shell-name' is preserved and always points to the default shell. For
|
||||
;; instance to use your fish shell environment variables set this variable to
|
||||
;; `/usr/local/bin/fish'.
|
||||
;; (default nil)
|
||||
dotspacemacs-import-env-vars-shell-file-name nil
|
||||
|
||||
;; Specify the startup banner. Default value is `official', it displays
|
||||
;; the official spacemacs logo. An integer value is the index of text
|
||||
;; banner, `random' chooses a random text banner in `core/banners'
|
||||
|
|
|
@ -1733,12 +1733,13 @@ build of Emacs.
|
|||
At anytime you can import the environment variables by calling the function
|
||||
=spacemacs/loadenv=.
|
||||
|
||||
You can define a different shell than the default shell by setting the variable
|
||||
=shell-file-name= in the =dotspacemacs/user-init= function of your dotfile.
|
||||
You can define a different shell than the default shell to look for environment
|
||||
variables by setting the variable =dotspacemacs-import-env-vars-shell-file-name=
|
||||
in your dotfile. Note that =shell-file-name= is not modified by this value.
|
||||
|
||||
#+BEGIN_EXAMPLE emacs-lisp
|
||||
(defun dotspacemacs/user-init ()
|
||||
(setq shell-file-name "/usr/local/bin/fish"))
|
||||
(defun dotspacemacs/init ()
|
||||
(setq dotspacemacs-import-env-vars-shell-file-name "/usr/local/bin/fish"))
|
||||
#+END_EXAMPLE
|
||||
|
||||
* Commands
|
||||
|
|
|
@ -18,8 +18,13 @@
|
|||
(require 'async nil t)
|
||||
(async-start
|
||||
`(lambda ()
|
||||
,(async-inject-variables "\\`shell-file-name\\'")
|
||||
(split-string (shell-command-to-string "env") "\n"))
|
||||
,(async-inject-variables
|
||||
"\\`dotspacemacs-import-env-vars-shell-file-name\\'")
|
||||
(if dotspacemacs-import-env-vars-shell-file-name
|
||||
(let ((shell-file-name
|
||||
dotspacemacs-import-env-vars-shell-file-name))
|
||||
(split-string (shell-command-to-string "env") "\n"))
|
||||
(split-string (shell-command-to-string "env") "\n")))
|
||||
(lambda (envvars)
|
||||
(spacemacs-buffer/message "Imported environment variables:")
|
||||
(dolist (env envvars)
|
||||
|
@ -29,8 +34,14 @@
|
|||
(v (cadr var)))
|
||||
(spacemacs-buffer/message " - %s=%s" k v)
|
||||
(if (string-equal "PATH" k)
|
||||
(setq exec-path (split-string v path-separator))
|
||||
(setenv k v))))))))
|
||||
(let ((paths (split-string v path-separator)))
|
||||
(dolist (p paths)
|
||||
(add-to-list 'exec-path p)))
|
||||
(setenv k v)))))
|
||||
;; be sure we keep the default shell in this Emacs session
|
||||
;; this is to prevent potential issues with packages which could
|
||||
;; expect a default shell
|
||||
(setenv "SHELL" shell-file-name))))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue