zsh 和 emacs 的优缺点(e) 外壳

发布于 2024-09-27 03:42:29 字数 844 浏览 0 评论 0原文

我目前已切换到 emacs (aquamacs),并且正在将我的整个工作流程一次一步地迁移到其中(组织模式、dired 等,从探路者、符号速度等)。

我尚未尝试的一件事(似乎是迄今为止最大的障碍)是内置的 emacs shell(shell 和/或 eshell,这里称为“eshell”),因为 zsh 设置完美我。不确定是否有一种方法可以基本上镜像/最小化所需的转换/适应步骤......

我的问题:

  1. eshell 可以被视为 zsh 的超集(即,eshell 可以做 zsh 可以做的所有事情,还有更多) )?我认为与标准 shell(bash、zsh、ksh、tcsh 等)相比,eshell 缺乏很多,否则它将成为标准 shell 之一(如果我这样想是错误的,请纠正我)。< /p>

  2. 通过 zsh 使用 eshell 的主要限制是什么?有人从 zsh 切换到 eshell 并觉得您严重错过了 zsh 的某些方面吗?

  3. 有人知道任何进行 zsh/eshell 功能比较的链接/资源吗?

  4. 此外,有关于从常用 shell 更改为 eshell 的资源吗?关于工作流程迁移的建议?

  5. 如果eshell没有zsh那么“强大”,那么eshell相对于zsh有什么优势呢?关于在 emacs 中使用 eshell 的任何提示和技巧可以说明学习它所花费的时间吗?

  6. 如果 eshell 能满足我认为我所需要的一切,人们是否应该放弃 eshell 并继续使用 zsh?或者少数“强大的工作流程”是否值得(我不知道)?

提前谢谢。

i have currently switched over to emacs (aquamacs) and am in the process of migrating my entire workflow into it one step at a time (org-mode, dired, etc., from pathfinder, notational velocity, etc.).

the one thing i have yet to try (and seems to be the biggest obstacle thus far) is the built-in emacs shell (shell and/or eshell, here on referred to as "eshell"), due to having zsh setup perfectly for me. unsure if there is a way to essentially mirror/minimize the conversion/adaptation steps required.....

my questions:

  1. can eshell be treated as a superset of zsh (i.e., eshell can do everything that zsh can, plus more)? i assume eshell lacks quite a bit compared to standard shells (bash, zsh, ksh, tcsh, etc.), otherwise it would be one of the standard shells (correct me if i'm wrong to think about it that way).

  2. what are the main limitations in using eshell over zsh? any folks switch from zsh to eshell and feel there are aspects of zsh you critically miss?

  3. anyone know of any links/resources doing a zsh/eshell feature comparison?

  4. further, any resources on making the change from one's usual shell to eshell? advice on workflow migration?

  5. if eshell isn't as "powerful" as zsh, then what advantage does eshell have over zsh? any tips and tricks on using eshell within emacs that would illustrate the time spent learning it?

  6. should one just give up on eshell and continue using zsh if it does everything i think i need? or are the few "power workflows" worth it (of which i'm not aware of)?

thnx in advance.

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

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

发布评论

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

评论(3

大海や 2024-10-04 03:42:29

关于Mx eshell

  1. Eshell 不是一个独立的 shell;它是一个独立的 shell。它是在纯 elisp 中实现的,因此不能在 emacs 之外运行,这就是为什么它不是标准 shell 之一。它没有自己的脚本语言,如 bash/zsh/等。有;它有 elisp 和一些命令解释的东西,使调用 elisp 更干净一些。

  2. 我无法比较 zsh 与 eshell,但我大部分时间都从 bash 切换到 eshell。 95% 的情况下,eshell 可以毫无问题地完成我想要或需要的一切。我不使用它进行 ssh。另外,一旦进程启动,您就无法将其置于后台(但您可以在后台启动它)。

  3. 这将非常困难,因为 zsh 有完整的脚本语言,而 eshell 基本上是 elisp 解释器的接口。您在交互式 shell 中寻找什么? Eshell 可能可以完成大部分工作。命令行上的条件语句和循环?当然。别名、函数、通配符、可编程补全?当然。

  4. 我的迁移方式基本上是从头开始。每当我遇到一些我不喜欢或我希望它发生的事情时,我就会想办法让它做我想做的事。例如,eshell 使用 pcomplete.el 进行可编程补全,因此添加补全功能非常容易。

  5. 与 emacs 的集成对我来说是一个巨大的胜利。您可以将 elisp 函数通过管道传输到 shell 命令。对于一个愚蠢的例子,请尝试:

    message "hello world" | cut -f 1 -d ' '

    一些命令(特别是 grep)被放入 emacs 缓冲区中,因此您可以快速跳转到结果。

  6. 取决于你真正花在 emacs 上的时间。如果您在 emacs 中执行所有操作,那么它会很有用,因为有时通过 eshell 将 elisp 命令与其他命令连接在一起会更容易。如果您没有发现自己在 emacs 和 shell 之间过于频繁地进行复制粘贴,那么这可能不会是一个胜利,您将不得不花时间对其进行自定义,直到您感到满意为止。< /p>

作为 eshell 的替代方案,Mx shell 运行您的普通 shell,它解释所有命令(因此无法访问 elisp 函数),同时进行命令行编辑(因此可编程完成、历史记录、等)是由 emacs 完成的。我用它来进行 ssh。

另一种选择是 Mx term,它是 emacs 内部的终端仿真器,通常在下面运行一个 shell,并且 shell 执行所有正常操作。那么绝对不需要任何转换/适应步骤。

Regarding M-x eshell:

  1. Eshell is not a stand-alone shell; it's implemented in pure elisp, so can't be run outside emacs, which is why it's not one of the standard shells. It doesn't have its own scripting language like bash/zsh/etc. have; it has elisp, and some command interpretation stuff to make calling elisp a little cleaner.

  2. I can't speak to zsh vs eshell, but I've mostly switched from bash to eshell. 95% of the time, eshell does everything I want or need without any problems. I don't use it for ssh. Also, you can't background a process once it's started (but you can start it backgrounded).

  3. It's going to be really hard, because zsh has a full scripting language, whereas eshell is basically an interface to the elisp interpreter. What are you looking for in an interactive shell? Eshell can probably do most of it. Conditional statements and loops on the command line? Sure. Aliases, functions, wildcards, programmable completion? Sure.

  4. The way I migrated was to basically start from scratch. Every time I ran into something that I didn't like or I wished it did, I'd figure out how to get it to do what I want. For example, eshell uses pcomplete.el for programmable completion, so adding completion functions is pretty easy.

  5. Integration with emacs is the big win for me. You can have elisp functions piped to shell commands. For a silly example, try:

    message "hello world" | cut -f 1 -d ' '

    Some commands (notably grep) get put in emacs buffers, so e.g. you can quickly jump to the results.

  6. Depends on how much time you really spend in emacs. If you do everything in emacs, it's useful, because sometimes it's easier to pipe together elisp commands with other commands through eshell. If you don't find yourself copy&pasting between emacs and your shell too frequently, it's probably not going to be a win, and you're going to have to spend time customizing it to the point you're comfortable with it.

As an alternative to eshell, M-x shell runs your normal shell underneath which interprets all the commands (so doesn't have access to elisp functions), while command-line editing (and therefore programmable completion, history, etc.) is done by emacs. I use it for ssh.

One other alternative is M-x term, which is a terminal emulator inside emacs, and usually runs a shell underneath, and the shell does all of its normal things. Then there's absolutely no conversion/adaptation steps required.

蓝海似她心 2024-10-04 03:42:29

不同的语法

由于 eshell 允许将 elisp 代码与 shell 命令混合,因此它有一些相当不寻常的语法,您需要小心。

需要注意的一件事是命令扩展的语法:zsh 使用该语法

file $(which foo)

相同的事情

file (which foo)

,但在 eshell 中,这基本上意味着与运行 文件 命令对 elisp 表达式 (which foo) 求值的结果执行命令,这通常会导致如下错误:

Symbol's function definition is void: which

事实证明,在 eshell 中编写此命令的方式实际上是

file ${which foo}

Portability

Through < code>eshell 是用平台中立的 Emacs Lisp 代码编写的,它在 Windows 原生 Emacsen 上的工作方式与在 *nix 上的工作方式基本相同,开箱即用(当然您可能会想要coreutils 等);让 shell-mode 与 *nix shell 一起工作可能至少有些棘手。

我想我在完成绝对路径时看到了一些奇怪的地方,因为驱动器号后面有冒号,但这并不完全是一个表演障碍......

Different Syntax

Since eshell allows mixing elisp code in with shell commands, it has some rather unusual syntax, which you'll need to be careful of.

One thing to watch out for is the syntax for command expansion: zsh uses the syntax

file $(which foo)

but in eshell this means basicaly the same thing as

file (which foo)

which means to run the file command on the result of evaluating the elisp expression (which foo), which typically results in an error like this:

Symbol's function definition is void: which

It turns out that the way to write this in eshell is actually

file ${which foo}

Portability

Since eshell is written in platform-neutral Emacs Lisp code, it works in essentially the same way on Windows-native Emacsen as it does on *nix, right out of the box (though of course you'll probably want coreutils and suchlike); getting shell-mode to work with a *nix shell there is presumably at least somewhat trickier.

I think I have seen some wonkiness with completion of absolute paths, though, because of the colon after the drive letter, but that's not exactly a show-stopper...

许你一世情深 2024-10-04 03:42:29

我认为你的 6 个问题都可以转化为一个问题:
Emacs 可以做的所有事情都可以在 zsh 中完成吗?
答案是,而且还有更多。我不会说 shell、eshell 或其他一些 Emacs 模式,但我只是说 Emacs

shell,eshell 只是 Emacs 的模式,如果我能找到一种方法或模式至少可以做 zsh 可以做的任何事情,那么它回答了你的问题。方法是 Emacs 中的 ansi-term 模式,它可以在 Emacs 中完美运行 zsh,如果你无法在 shell 或 eshell 中完成你的工作,你可以切换到 ansi-term Emacs 模式,所以你的问题已经消失了。

eshell 只是省略了 shell 并且那些不擅长交互式/滚动命令,例如 topless 等。

I think all your 6 questions can be translated to just one question:
All things can be done in zsh that can be done in Emacs?
The answer is YES and there are more. I'd not say shell, eshell or other some Emacs' mode yet I just say Emacs.

shell, eshell just Emacs's mode, if I can find a way or mode at least in which can do anything that zsh can do, so it answers your question. The way is ansi-term mode in Emacs, it can run zsh inside Emacs perfectly, if you can't do your job in shell or eshell you can switch to ansi-term mode in Emacs, so your question has gone.

eshell just elisped shell and those is not good at interactive/scrolling commands such as top, less, etc.

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