zsh 和 emacs 的优缺点(e) 外壳
我目前已切换到 emacs (aquamacs),并且正在将我的整个工作流程一次一步地迁移到其中(组织模式、dired 等,从探路者、符号速度等)。
我尚未尝试的一件事(似乎是迄今为止最大的障碍)是内置的 emacs shell(shell 和/或 eshell,这里称为“eshell”),因为 zsh 设置完美我。不确定是否有一种方法可以基本上镜像/最小化所需的转换/适应步骤......
我的问题:
eshell 可以被视为 zsh 的超集(即,eshell 可以做 zsh 可以做的所有事情,还有更多) )?我认为与标准 shell(bash、zsh、ksh、tcsh 等)相比,eshell 缺乏很多,否则它将成为标准 shell 之一(如果我这样想是错误的,请纠正我)。< /p>
通过 zsh 使用 eshell 的主要限制是什么?有人从 zsh 切换到 eshell 并觉得您严重错过了 zsh 的某些方面吗?
有人知道任何进行 zsh/eshell 功能比较的链接/资源吗?
此外,有关于从常用 shell 更改为 eshell 的资源吗?关于工作流程迁移的建议?
如果eshell没有zsh那么“强大”,那么eshell相对于zsh有什么优势呢?关于在 emacs 中使用 eshell 的任何提示和技巧可以说明学习它所花费的时间吗?
如果 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:
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).
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?
anyone know of any links/resources doing a zsh/eshell feature comparison?
further, any resources on making the change from one's usual shell to eshell? advice on workflow migration?
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?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于
Mx eshell
:Eshell 不是一个独立的 shell;它是一个独立的 shell。它是在纯 elisp 中实现的,因此不能在 emacs 之外运行,这就是为什么它不是标准 shell 之一。它没有自己的脚本语言,如 bash/zsh/等。有;它有 elisp 和一些命令解释的东西,使调用 elisp 更干净一些。
我无法比较 zsh 与 eshell,但我大部分时间都从 bash 切换到 eshell。 95% 的情况下,eshell 可以毫无问题地完成我想要或需要的一切。我不使用它进行 ssh。另外,一旦进程启动,您就无法将其置于后台(但您可以在后台启动它)。
这将非常困难,因为 zsh 有完整的脚本语言,而 eshell 基本上是 elisp 解释器的接口。您在交互式 shell 中寻找什么? Eshell 可能可以完成大部分工作。命令行上的条件语句和循环?当然。别名、函数、通配符、可编程补全?当然。
我的迁移方式基本上是从头开始。每当我遇到一些我不喜欢或我希望它发生的事情时,我就会想办法让它做我想做的事。例如,eshell 使用 pcomplete.el 进行可编程补全,因此添加补全功能非常容易。
与 emacs 的集成对我来说是一个巨大的胜利。您可以将 elisp 函数通过管道传输到 shell 命令。对于一个愚蠢的例子,请尝试:
一些命令(特别是 grep)被放入 emacs 缓冲区中,因此您可以快速跳转到结果。
取决于你真正花在 emacs 上的时间。如果您在 emacs 中执行所有操作,那么它会很有用,因为有时通过 eshell 将 elisp 命令与其他命令连接在一起会更容易。如果您没有发现自己在 emacs 和 shell 之间过于频繁地进行复制粘贴,那么这可能不会是一个胜利,您将不得不花时间对其进行自定义,直到您感到满意为止。< /p>
作为 eshell 的替代方案,
Mx shell
运行您的普通 shell,它解释所有命令(因此无法访问 elisp 函数),同时进行命令行编辑(因此可编程完成、历史记录、等)是由 emacs 完成的。我用它来进行 ssh。另一种选择是 Mx term,它是 emacs 内部的终端仿真器,通常在下面运行一个 shell,并且 shell 执行所有正常操作。那么绝对不需要任何转换/适应步骤。
Regarding
M-x eshell
: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.
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).
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.
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.
Integration with emacs is the big win for me. You can have elisp functions piped to shell commands. For a silly example, try:
Some commands (notably grep) get put in emacs buffers, so e.g. you can quickly jump to the results.
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.不同的语法
由于
eshell
允许将elisp
代码与 shell 命令混合,因此它有一些相当不寻常的语法,您需要小心。需要注意的一件事是命令扩展的语法:
zsh
使用该语法相同的事情
,但在
eshell
中,这基本上意味着与运行文件
命令对 elisp 表达式(which foo)
求值的结果执行命令,这通常会导致如下错误:事实证明,在 eshell 中编写此命令的方式实际上是
Portability
Through < code>eshell 是用平台中立的 Emacs Lisp 代码编写的,它在 Windows 原生 Emacsen 上的工作方式与在 *nix 上的工作方式基本相同,开箱即用(当然您可能会想要coreutils 等);让
shell-mode
与 *nix shell 一起工作可能至少有些棘手。我想我在完成绝对路径时看到了一些奇怪的地方,因为驱动器号后面有冒号,但这并不完全是一个表演障碍......
Different Syntax
Since
eshell
allows mixingelisp
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 syntaxbut in
eshell
this means basicaly the same thing aswhich means to run the
file
command on the result of evaluating the elisp expression(which foo)
, which typically results in an error like this:It turns out that the way to write this in eshell is actually
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 wantcoreutils
and suchlike); gettingshell-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...
我认为你的 6 个问题都可以转化为一个问题:
Emacs 可以做的所有事情都可以在 zsh 中完成吗?
答案是是,而且还有更多。我不会说 shell、eshell 或其他一些 Emacs 模式,但我只是说 Emacs。
shell,eshell 只是 Emacs 的模式,如果我能找到一种方法或模式至少可以做 zsh 可以做的任何事情,那么它回答了你的问题。方法是 Emacs 中的
ansi-term
模式,它可以在 Emacs 中完美运行 zsh,如果你无法在 shell 或 eshell 中完成你的工作,你可以切换到ansi-term
Emacs 模式,所以你的问题已经消失了。eshell
只是省略了shell
并且那些不擅长交互式/滚动命令,例如top
、less
等。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 toansi-term
mode in Emacs, so your question has gone.eshell
just elispedshell
and those is not good at interactive/scrolling commands such astop
,less
, etc.