eshell (elisp shell) 启动时读取什么设置文件? eshell 如何设置它的 PATH?

发布于 2024-09-17 12:33:27 字数 375 浏览 4 评论 0原文

使用 emacs/eshell,“echo $PATH”显示与 $PATH 环境变量不同的路径。

我还检查了 eshell 不读取 .bashrc 或 .profile,我认为这就是路径不同的原因。

  • eshell 启动时读取什么设置文件?
  • eshell 如何设置它的 PATH?
  • 如何使eshell的PATH与环境变量的PATH相同?

添加

正如 Jérôme Radix 指出的那样,路径取决于我如何启动 Aquamcs。

  • 当我单击按钮启动 Aquamacs 时,它有不同的路径。
  • 当我从命令行运行“aquamacs”时,它具有相同的路径。

With emacs/eshell, the "echo $PATH" shows different paths than that of $PATH environment variable.

And I also checked that eshell doesn't read .bashrc or .profile, and I think that's the reason why the path is different.

  • What setup file does eshell read when it starts?
  • How eshell sets its PATH?
  • How to make the eshell's PATH the same as the environment variable's PATH?

ADDED

As Jérôme Radix pointed out, the PATH depends on how I start the Aquamcs.

  • When I click the button to start Aquamacs, it has different PATH.
  • When I run 'aquamacs' from the command line, it has the same PATH.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一腔孤↑勇 2024-09-24 12:33:27
  • eshell启动时读取什么安装文件?

启动时不执行安装文件。读取以下文件来定义初始历史记录和最后目录:

~/.eshell/history
~/.eshell/lastdir
  • eshell 如何设置其 PATH?

In esh-util.el,第 240 行:

(defvar eshell-path-env (getenv "PATH")
  "Content of $PATH.
It might be different from \(getenv \"PATH\"\), when
`default-directory' points to a remote host.")
  • 如何使 eshell 的 PATH 与环境变量的PATH?

与emacs进程的PATH变量相同。我想象你在 emacs 外部的 shell 上执行 echo $PATH 来进行比较。如果 emacs 和 emacs 外部的 shell 之间的 PATH 不同,那是因为 emacs 和您的 shell 不执行相同的启动脚本。

  • What setup file does eshell read when it starts?

No setup file is executed at startup. The following files are read to define the initial history and last directories :

~/.eshell/history
~/.eshell/lastdir
  • How eshell sets its PATH?

In esh-util.el, line 240 :

(defvar eshell-path-env (getenv "PATH")
  "Content of $PATH.
It might be different from \(getenv \"PATH\"\), when
`default-directory' points to a remote host.")
  • How to make the eshell's PATH the same as the environment variable's PATH?

It is the same as the PATH variable of the emacs process. I imagine that you do a echo $PATH on a shell outside emacs to compare. If PATH are differents between emacs and your shell outside emacs it is because emacs and your shell does not execute the same startup scripts.

独闯女儿国 2024-09-24 12:33:27

由于您使用的是 Mac,因此重要的是要知道 GUI 应用程序(例如未从终端打开时的 Aquamacs)从 ~/.MacOSX/environment.plist 获取其环境,以便您可以进行更改那里。请特别参阅 Brian D Foy 撰写的这篇文章,了解自动构建此文件的方法。

Since you are on a Mac, it's important to know that GUI applications (such as Aquamacs when not opened from a terminal) get their environment from ~/.MacOSX/environment.plist, so you can make changes there. See in particular this article by Brian D Foy for a way to build this file automatically.

╭ゆ眷念 2024-09-24 12:33:27

根据定义,echo $PATH 显示 PATH 环境变量的值。在 Emacs 中运行的 shell 从正在运行的 Emacs 进程继承 PATH 环境变量。

<编辑>
eshell 中运行的 shell 不像 bash 那样是一个单独的程序,它内置于 Emacs 中。它的定制是通过 Emacs Lisp 完成的。特别是,当 eshell 启动时,它会运行 eshell-mode-hook 中的函数并加载 eshell-modules-list 中的 Lisp 文件。

您似乎没有在正确的配置文件中设置PATH。正确的位置应该是在会话开始时完成的事情。这取决于操作系统;如果您遇到问题,请询问超级用户,确保说出您的操作系统是什么,如果适用,请指出您的登录 shell、桌面环境等

By definition, echo $PATH shows the value of the PATH environment variable. The shell running inside Emacs inherits the PATH environment variable from the running Emacs process.

<EDIT>
The shell running in eshell is not a separate program like bash, it's built into Emacs. Its customization is done through Emacs Lisp. In particular, when eshell starts, it runs the functions in eshell-mode-hook and loads the Lisp files in eshell-modules-list.
</EDIT>

It looks like you're not setting PATH in the right configuration file. The right place would be something that's done at the start of your session. This is operating system-dependent; if you have trouble with that, ask on Super User, making sure to say what your operating system is, and if applicable indicate your login shell, desktop environment, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文