Advantages and disadvantages between zsh and emacs' (e)shell Advantages and disadvantages between zsh and emacs' (e)shell shell shell

Advantages and disadvantages between zsh and emacs' (e)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.


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...


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.