Eshell - 默认目录和定义的路径在哪里?
关于Eshell配置的两个小问题。我查看了自定义选项甚至源代码,但无济于事。也许我应该仔细看看。
当我启动 Emacs 并打开 Eshell 时,目录是“~/.emacs.d/elpa”,而不是我所期望的主目录“~/”。我不知道这个配置从哪里来,也没有找到改变它的方法。
我在 .bashrc 中更改了 $PATH,并根据需要自定义了 Emacs 变量“exec-path”。然而,第一个变化并没有被 Eshell 反映,它不知道,而 bash 知道。 Eshell 如何获取此信息?它在了解此变量的更改方面与 bash 有何不同?
感谢您提供任何提示
Thorsten
PS
我发现了一个类似的问题[这里](http://stackoverflow.com/questions/3621755/what-setup-file-does-eshell-elisp-shell-read-when-it-starts-how -eshell-集-i)。第 2 点的答案是 eshell 不读取 .bashrc,因此 $PATH 必须设置在启动过程中较早读取的文件中。在我的 Ubuntu 系统上,
/etc/environment
似乎是 Emacs 在启动时读取的文件来设置 $PATH。
Two little questions with regards to the configuration of Eshell. I looked at the customization options and even the source code, but to no avail. Maybe I should have taken a better look.
When I start Emacs and open Eshell, the directory is '~/.emacs.d/elpa' instead of my home directory '~/’, what I would expect. I have no idea, where this configuration comes from, and did not find a way to change it.
I changed $PATH in my .bashrc and I customized the Emacs variable 'exec-path' to my needs. However, the first change is not reflected by Eshell, it does not know about it, while bash does. How does Eshell get this information, and how comes it differs from bash in its knowledge about changes in this variable?
Thanks for any hints
Thorsten
PS
I found a similar question [here] (http://stackoverflow.com/questions/3621755/what-setup-file-does-eshell-elisp-shell-read-when-it-starts-how-eshell-sets-i). The answer to point 2. is that eshell does not read .bashrc, therefore $PATH must be set in a file that is read earlier in the start-up process. On my Ubuntu system
/etc/environment
seems to be the file that is read by Emacs on start-up to set $PATH.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
eshell 似乎在当前工作目录中启动,对您来说(Emacs 启动后)是“~/.emacs.d/elpa”。您可以使用“Mx cd”手动更改它,但这不是必需的。如果您编辑某个文件并从其缓冲区启动 eshell,则 eshell 将在与该文件相同的目录中启动。
但如果您确实想启动主目录中的每个 eshell 会话,您可以在 eshell 启动之前进行钩子调用“cd”。
eshell seems to start in the current working directory, which for you (right after Emacs started) is "~/.emacs.d/elpa". You can change it manually with "M-x cd", but that shouldn't be necessary. If you edit some file and start eshell from its buffer, eshell will start in the same directory as the file.
But if you really want to start every eshell session in your home directory, you can make a hook call "cd" before eshell starts.
正如 Q1 中已经提到的:当 eshell 启动时,eshell 会在当前缓冲区的目录中启动。如果我没记错的话(这不是给定的),在 macOS 上,当 emacs 通过 Finder 启动(即双击图标)时,在短时间内,当前缓冲区为
*scratch*
是 root/
。现在,当查找器启动时,*scratch*
的当前缓冲区是我的主目录。对于问题 2:您要设置的变量是
eshell-path-env
。这是用冒号分隔的路径列表。我已经在使用 .dir-locals.el 来设置目录特定变量,因此我打算这样做,但我确信您可以使用启动挂钩。
请记住,
eshell
不是bash
、zsh
、csh
等。它是永远不会读取它们的 rc 文件,也不会读取/etc/environment
等。与comint-mode
衍生物不同,它不是emacs
的子进程,但完全包含在emacs
。我发现掌握 Eshell 非常有帮助。
As already mentioned for Q1: eshell starts up in the directory of the current buffer when eshell is started. If I recall correctly (which is NOT a given), on macOS for a short period of time, when emacs was started by the Finder (i.e. double clicking the icon), the current buffer for
*scratch*
was root/
. Now, when it is started by the finder, the current buffer for*scratch*
is my home directory.For Q2: the variable that you want to set is
eshell-path-env
. This is a colon separated list of paths.I'm already using
.dir-locals.el
to set directory specific variables so I plan to do it that way but I'm sure there are start up hooks that you can use.Remember that
eshell
is notbash
,zsh
,csh
, etc. It is not ever going to read their rc files nor does it read/etc/environment
, etc. Unlikecomint-mode
derivatives, it is not a subprocess ofemacs
but is wholly contained withinemacs
.I found Mastering Eshell to be extremely helpful.