[英]Emacs OS X: inferior shell $PATH inheritance
Emacs manual says the following: Both M-! and M-| use shell-file-name to specify the shell to use. This variable is initialized based on your SHELL environment variable when Emacs is started. If the file name does not specify a directory, the directories in the list exec-path are searched; this list is initialized based on the environment variable PATH when Emacs is started. Your .emacs file can override either or both of these default initializations.
Emacs手册说以下内容:
Both M-! and M-| use shell-file-name to specify the shell to use. This variable is initialized based on your SHELL environment variable when Emacs is started. If the file name does not specify a directory, the directories in the list exec-path are searched; this list is initialized based on the environment variable PATH when Emacs is started. Your .emacs file can override either or both of these default initializations.
Both M-! and M-| use shell-file-name to specify the shell to use. This variable is initialized based on your SHELL environment variable when Emacs is started. If the file name does not specify a directory, the directories in the list exec-path are searched; this list is initialized based on the environment variable PATH when Emacs is started. Your .emacs file can override either or both of these default initializations.
shell-file-name
is set to /usr/local/bin/zsh
in terminal, echo $SHELL
is usr/local/bin/zsh
and echo $PATH
is /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
在终端中将
shell-file-name
设置为/usr/local/bin/zsh
, echo $SHELL
为usr/local/bin/zsh
, echo $PATH
为/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
However, Mx ! echo $SHELL
但是,
Mx ! echo $SHELL
Mx ! echo $SHELL
is /bin/zsh
and Mx ! echo $PATH
Mx ! echo $SHELL
是/bin/zsh
和Mx ! echo $PATH
Mx ! echo $PATH
is /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Mx ! echo $PATH
是/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Why is this so? 为什么会这样呢? How do I change it to be the same with the terminal $PATH?
如何将其更改为与$ PATH终端相同?
I'm not sure of the specifics, but I think what you want is to set PATH
in your .emacs
, and that exec-path
is used to search for your shell executable, not used by your shell executable. 我不知道具体情况,但我想你想要的是设置
PATH
在你.emacs
,并且exec-path
来寻找你的shell可执行文件,不使用你的shell执行。
Basically to put a desired directory at the front of $PATH
, you want something like: 基本上,将所需的目录放在
$PATH
的前面,您需要类似以下内容:
(setenv "PATH" (concat my-dir ":" (getenv "PATH")))
Some guides suggest you also do (add-to-list 'exec-path my-dir)
when you do this in .emacs
, I think just to keep the search paths of Emacs and its inferior shells in sync. 一些指南建议您在
.emacs
执行此操作时也要执行此操作(add-to-list 'exec-path my-dir)
,我想只是为了使Emacs及其劣质shell的搜索路径保持同步。
But hey, it's been almost a year, hopefully you've found a workaround by now. 但是,已经快一年了,希望您现在已经找到了解决方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.