Skip to content

Mastering Eshell

by mickey on December 13th, 2010

There are several shells for Emacs, but none can match the versatility and integration with Emacs like Eshell. Eshell is a shell written entirely in Emacs-Lisp, and it replicates most of the features and commands from GNU CoreUtils and the Bourne-like shells. So by re-writing common commands like ls and cp in Emacs-Lisp, Eshell will function identically on any environment Emacs itself runs on.

Unfortunately, there is a problem: Eshell is woefully underdocumented — a rare sight in GNU Emacs — so I’ve compiled this guide to help people make full use of what Eshell has to offer.

Overview

Unlike the other shells in Emacs, Eshell does not inherit from comint-mode, the default mode for interacting with inferior processes in Emacs. But because Eshell is not an inferior process, it does not have to use comint; but while that may seem like a good thing, it does mean that hooks and routines written for comint-mode won’t work with Eshell.

However, almost all the Emacs commands common to comint-mode are reimplemented natively in Eshell — and most share the same keybinds — but there are a few new advances that haven’t been ported over to Eshell, like the spiffy comint-history-isearch-backward-regexp in Emacs 23.2, bound to M-r.

Eshell works well on any platform Emacs itself runs on, as Eshell interacts with a common middleware (namely the Emacs-Lisp/C source library) and that middleware will in turn communicate with your OS on how to go about copying files and what have you. That middleware support enables Eshell to take advantage of TRAMP as well.

Given Emacs’ UNIX origin, Eshell emulates traditional UNIX shells like bash and the GNU toolchain. This is good news if you are using Windows and cannot be bothered fidgeting with cygwin, or if you require a completely portable Emacs with few or no external dependencies.

And actually, the Windows support in Eshell is a lot better, in many ways, than cygwin’s bash. You do not have the /cygdrive/c crud to contend with, as Eshell natively supports Windows/MS-DOS drive paths (so cd D: and D: both work equally well.)

Despite all the advantages offered by Eshell, there are some points I want to make that seem to confuse some people:

  1. Eshell is not a terminal emulator. It does not talk to a shell, for it is the shell. Everything it does — from displaying stuff on the screen, to fetching the contents of a directory — it does through Emacs, and Emacs in turn talks to your operating system.
  2. Because of the way Eshell talks to other processes (asynchronous ones especially) there may be issues with the way it buffers text and how interrupts work.
  3. Eshell does not support interactive (or “visual” in Eshell parlance) programs, like top, directly; you must tell Eshell to launch them in a separate ansi-term instance instead.
  4. It is not bash or zsh or even csh; do not treat it as such, even though it is heavily inspired by them. To use Eshell effectively you should treat it as if you are using a completely alien shell.

Commands

Eshell is capable of invoking almost any elisp function loaded in Emacs. That sort of flexibility is unmatched; there are no shells out there capable of approximating what Eshell can do. In fact, this functionality is heavily used (and encouraged!) by Eshell. If you want to open the file foobar.txt in Emacs you simply invoke find-file foobar.txt and Eshell will map that to the elisp call (find-file "foobar.txt") and open the file for you.

Technical Details

All commands evaluated by Eshell have an evaluation order, which is an ordered list your command must pass through to determine what part of Eshell handles it. If there is nothing on the list that wants to evaluate your command, you will be told your command is invalid.

Assuming you want to execute the command cp, the evaluation order is:

  1. A full filepath (e.g. /bin/cp) runs cp in /bin
  2. Look for the command prefix, eshell-explicit-command-char (default is *), and if it is found then look for the command in the search path.
  3. Look for a shell-defined alias (alias command)
  4. Look for cp in the search path, $PATH (or eshell-path-env)
  5. Look for a Lisp function named cp or the elisp function eshell/cp

The variable eshell-prefer-lisp-functions makes internal elisp calls take priority over external calls. What that means is when it’s set to t Eshell will look for an elisp function first, instead of last. If the command prefix is specified, though, this directive is ignored.

Built-In Commands

Eshell has a handful of commands written in Emacs-Lisp that closely emulate a large subset of what the real GNU Coreutils (or your favorite shell) has. Those commands are called "Alias functions."

EShell only implements a subset of the functionality provided by the real commands, but if you pass an unknown argument to Eshell it will defer to the real commandline tool (if it is installed) automatically.

Here’s what Eshell currently re-implements in elisp:

cat, cp, ls, cd, export, dirs, du, echo, env, kill, ln, mkdir, mv, alias, popd, pushd, pwd, rm, rmdir, time, umask.

There is a big emphasis on adhering to the original GNU functionality, so the fact they are emulated is unlikely to cause you any trouble.

Command Interception

Eshell has a cool mechanism where certain commands are intercepted and passed on to Emacs proper. This enables you to invoke a command like man ls and have Emacs’s built-in man formatter handle it instead. This functionality is especially important for interactive commands (as they will not work properly in Eshell) as Eshell would not be able to call them otherwise.

But where the feature really shines is with complex commands like grep, or diff as Emacs comes with awesome grep and diff tools built in. This feature alone shows the power of Eshell.

The following commands are redirected to Emacs proper:

agrep, diff, egrep, fgrep, glimpse, grep, info, jobs, locate, man, occur, su, sudo, whoami.

The commands su, sudo and whoami are TRAMP aware commands (in Emacs 23.2), so if you are connected to a remote shell they work as expected.

Subshells

You can use $() to in-line elisp calls and use their output as arguments, in much the same way as you would in bash. The only caveat here is you cannot use the backquote (backtick) to spawn a subshell, but that syntax was never universally supported anyway. It’s also possible (though I would not recommend it, for there are cases where it does not work) to use a standard elisp form like this: (form ...) — so the same as the subshell syntax I explained before, but without the $.

Useful Elisp Commands

Eshell comes with a selection of helper functions that make your day-to-day life just . That, combined with the power to invoke almost any elisp function, means you have incredible flexibility and control over your shell. Some of the commands I’ve listed in the table below were written for Eshell specifically, and the rest are elisp commands I find useful.

I’ve compiled a table of elisp functions (some are made for Eshell; others are not.)

Command Description
listify ARGS Parses an argument string into elisp list notation and prints it to the screen. It’s clever enough to handle both MS-DOS/Windows and POSIX-style argument syntax.
addpath PATH Adds the argument, which must be a path, to the $PATH environment variable. If no argument is specified the existing paths are pretty-printed to the screen.
unset ENV-VAR Unsets an existing environment variable
find-file FILE Finds the file FILE and opens it in Emacs. This function is TRAMP aware and will therefore work remotely.
dired DIRECTORY Opens a dired buffer in DIRECTORY.
calc-eval EXPR Runs EXPR through the Emacs calculator.
upcase STR/downcase STR Converts STR to upper- or lowercase.
vc-dir DIRECTORY Reports the status of a version controlled directory (equivalent to the status command in most VCS)
ediff-files FILE1 FILE2 Diffs FILE1 and FILE2 using ediff, Emacs’ diff engine.

If you’re an Eshell user and you use elisp commands not listed in the table above, post a comment and let tell me what it is.

Aliasing

Aliasing in Eshell works in much the same way as it does in other mainstream shells, except you can freely mix elisp and Eshell commands. The command alias takes an alias-name and a definition. The definition must be surrounded by single quotes. You can use the usual argument references known from other shells: $1 for the first argument, $2 for the second, …, or $* to use all arguments, or omit them entirely as Eshell will magically append them on to the end of a command if they weren’t referenced in the definition.

To delete an alias, simply leave out the definition argument and it will be removed automagically. To list all the aliases, leave out both arguments.

Eshell will write the alias definitions to eshell-aliases-file, which in turn is governed by the Eshell-directory-name and that put together means your alias file will be put in ~/.Eshell/alias by default. This is done every time you alter an alias.

Another useful thing to know is the auto-correcting aliasing. If you type an invalid command too many times (governed by eshell-bad-command-tolerance, which is 3 by default) Eshell will offer to alias it to its intended command for you. If you don’t like that, you can bump up the aforementioned variable to a large number.

Useful Examples

Let’s map the cumbersome command find-file to the more manageable ff:

And let’s map dired to d:

Visual Commands

Some commands are too complex to be displayed by Eshell directly, and require special handling. An example would be top, a program that won’t work with a dumb terminal. To support these commands Eshell will run a term session when you invoke a command Eshell considers visual.

To modify the list of visual commands, you can alter eshell-visual-commands.

Command History

Eshell comes with a feature-rich command history facility. Because Eshell does not use comint-mode it does not have all the history features available to it, but most of them are reimplemented.

Keybind Description
M-r / M-s Search backwards or forwards for a command by regexp
M-p / M-n Goes backwards or forwards in the command history list
C-p / C-n Jump to the previous or next command position in Eshell
C-c M-r / C-c M-s Jumps to the previous or next command that shares the command currently used as input. So it jumps to other instances of the command foo if that is the current input.

Unfortunately, the new-and-improved comint-history-isearch-backward-regexp (bound to M-r in comint) doesn’t work in Eshell because it not inherit from comint (and therefore misses out on upgrades.).

History Interaction

Like bash and other shells, Eshell has support for history modification and interaction. It’s probably easier to refer you to the bash info manual for detailed information on how the history interaction works. I’ve included a small table below that describes most of the history syntax Eshell supports.

Syntax Description
!! Repeats the last command
!ls Repeats the last command beginning with ls
!?ls Repeats the last command containing ls
!ls:n Extract the nth argument from the last command beginning with ls
!ls Using pcomplete, show completion results matches ls
^old^new Quick substitution. Using the last command, replaceold with new and run it again. Appears to be buggy.
$_ Returns the last parameter in the last executed command.

Eshell also has some support for bash history modifiers (like !!:s/old/new/) and the bash reference on history interaction would be a good place to brush up on that.

Commandline Interaction

The Eshell Prompt

You can customize the Eshell prompt by modifying eshell-prompt-function, a variable that takes a function that defines what the prompt should contain. By relegating prompt configuration to elisp you can do just about anything you like with it. The only problem is, of course, that Eshell will need to be told what the prompt “looks” like, so you must also edit the variable eshell-prompt-regexp so Eshell knows what the prompt is.

The Commandline

Eshell supports to escape newlines and supports rudimentary multi-line input that way. Another way of doing multi-line literal strings is with single quotes: begin a single quote and hit enter, and you are free to enter text until the closing quote delimiter is encountered. If you use double quotes Eshell will expand subshell commands and do variable expansion.

Due to the way Eshell works, you can even go back and modify the text you entered, in quotes. This is very handy as you can go back and change stuff you don’t like, and get it right the first time.

Useful Keybindings

Eshell comes equipped with a couple of quality-of-life improvements that make interacting with Emacs and Eshell a lot easier.

Keybind Description
C-c M-b Inserts the printed buffer name at point
C-c M-i Inserts the printed process name at point
C-c M-v Inserts an environment variable name at point
C-c M-d Toggles between direct input and delayed input (send on RET).

Useful for some programs that don’t work correctly with buffered input.

Argument Predicates

Argument predicates are a cool way of quickly filtering lists of files or even elisp lists. The predicate syntax is based on the one used in zsh, so if you are familiar with argument predication in zsh, you can apply most of your knowledge to Eshells’ version.

Unlike most other areas of Eshell, argument predicates are documented in Eshell itself. You can access the help files by typing eshell-display-predicate-help or eshell-display-modifier-help.

Filtering globbed lists of files is very useful, as it saves you the hassle of using tools like find or abusing ls to do your thing.

The help file is fairly spartan and only serves as a simple reference, so I’ve included a small guide here; but actually, the only real way to learn something as flexible as argument predication is simply by trial and error.

Syntax Reference

I’ve opted not to reprint the sizeable list of predicates and modifiers, as the Eshell manual (see the commands above) do a good enough job of explaining how they work.

Globbing

Globbing in Eshell follow the same rules as it does in most other common shells: it is the shell that does the expansion of globs and it passes the expanded list of matches on to commands like ls. That’s why when you use find and xargs together it’s critical that you pass -print0 to find, and -0 to xargs. If you don’t, filenames with obscure characters or spaces in them may trip up xargs; by using the NUL character as a separator ensures tokenization takes place correctly as the NUL character is an invalid character (along with /) in files.

Elisp Lists

Eshell’s “lists” are actually elisp lists in their printed form as well as internally. That makes life a lot simpler if you think about it, as Eshell can paw off list handling to elisp, which is something Lisp does well.

Simplest glob example is echo *, which echos a list of all the wildcard matches in the current directory. Because — as I just mentioned above — wildcard expansion takes place inline, I can immediately apply a modifier to the * wildcard above.

Let’s uppercase the globbed result set:

Notice how I used () immediately following the glob pattern. The brackets are what makes argument modifiers or predicates possible. Modifiers are things that modify (big surprise!) the resulting list. Modifier commands always begin with :, and predicates do not.

Another example, but this time I filter directories using a predicate:

The circumflex, ^, in this case, like in regular expressions, is negation. The / means “directories” only.

But I don’t have to use globs to apply modifiers or predicates to lists:

This time I replaced all occurrences of foo with blarg. Observe that the syntax is identical, except instead of using globs to get a list of files, I used a list of my own choosing.

The advantages provided by argument predicates and modifiers will greatly reduce commandline clutter as the predicates cover permissions, ownership, file attributes, and much more.

Adding New Modifiers and Predicates

You can even add your own predicates (eshell-predicate-alist) or modifiers (eshell-modifier-alist):

Here I’ve bound X to rot13, the substitution cipher:

Plan 9 Smart Shell

Eshell comes with a pared-down facsimile of Plan 9′s terminal, called the Eshell smart display. The smart display is meant to improve the write-run-revise cycle all commandline hackers go through. It works by not letting the point follow the output of a command you execute, like a normal terminal would. Instead, the point is kept on the line of the command you executed, letting you revise it easily without having to use M-p and M-n or the history modification commands.

If smart display is enabled it will also let you review the output of long-running commands by using SPC to move down a page and BACKSPACE to move up a page. If any other key is pressed it will jump the end of the buffer, essentially acting in the same way as if smart display wasn’t enabled.

Essentially, if Eshell detects that you want to review the last executed command, it will help you do so; if, on the other hand, you do not then Eshell will jump to the end of the buffer instead. It’s pretty clever about it, and there are switches you can toggle to fine-tune the behavior.

Where the smart display really shines is that it lets you modify the command you just executed by using the movement keys — like you normally would — to change the command, say to fix a typo or tweak an argument.

The smart display can also be set not to use this extended “edit mode” if the command returns successfully, and without displaying output, like chown for instance. This is how I prefer it.

To enable it put this in your .emacs file:

If Eshell has already initialized (that is, you’ve already launched an instance of Eshell in Emacs) then evaluating the changes above will not work. You must switch to the Eshell buffer and type M-: (shell-smart-initialize) (or restart Emacs.)

The smart display is a pretty useful feature and it won’t get in your way once you’re used to it. Simply typing in new commands will make Eshell jump to the end of buffer as if the point was already there.

Redirection

Redirection in Eshell works in much the same way as it does in other shells. The key difference is that Eshell has to emulate the pseudo-devices as they may not be present (or may not be present in the same form) on platforms such as Windows where /dev/null is actually NUL.

Another caveat is that Eshell does not support input redirection, though it does support output redirection. To skirt around the lack of input redirection you should use pipes instead.

Redirection to stdout, stdin and stderr work as you would expect, and you can send things to multiple targets as well, which is very nice.

To Emacs

Because Eshell has to reimplement pseudo-devices internally it is not at the mercy of dealing with just UNIX device files — it is actually capable of implementing its own pseudo-devices.

A good example would be redirection to a buffer of your choosing, and that can be done with the following syntax:

The keybind I mentioned before C-c M-b will insert the printed name of a buffer.

You can also output straight to an elisp symbol (but be careful you don’t fry the wrong settings):

If you set eshell-buffer-shorthand to t you can use the shorthand #'*scratch* instead, but it means you will not be able to redirect straight to elisp symbols.

To Pseudo-Devices

Eshell reimplements the following pseudo-devices:

Device Description
/dev/eshell Prints the output interactively to Eshell.
/dev/null Sends the output to the NULL device.
/dev/clip Sends the output to the clipboard.
/dev/kill Sends the output to the kill ring.

The usual redirection rules like overwrite (>) and append (>>) apply here.

To custom virtual targets

You can design your own virtual targets by modifying eshell-virtual-targets, an alist that takes the name of the pseudo-device you want to create, and a function that takes one parameter, mode, that determines if it’s overwrite, append or insert.

TRAMP

Eshell now supports TRAMP natively, which means commands like su, sudo and whoami now query the remote system if the directory Eshell is in is remote.

To use the TRAMP functionality simply enter the same TRAMP command string you’d use in C-x C-f and off it goes. The TRAMP support in Eshell can be a bit flakey, but it does give you a remote shell courtesy of TRAMP. You don’t have to limit your TRAMP use to remote shells, as TRAMP is also capable of using sudo and su for local use.

I’ll cover TRAMP in greater detail in a separate article, but the official manual is a good place to start.

Startup Scripts

Like most shells, Eshell supports both login and profile/rc shell scripts. The full filepaths for both are stored in the variables eshell-login-script and eshell-rc-script, but by default the files login and profile are stored in ~/.eshell/.

It bears mention that the comment syntax is #.

More Customization…

Eshell has hundreds of options you can tweak to your liking. To configure Eshell, type M-x customize-group RET eshell RET.

Conclusion

Phew. I think I’ve covered all major areas of Eshell, and I hope it paints it in a good light. Eshell is remarkably versatile thanks to its tight integration with Emacs. It’s not a full-on replacement for bash and your favorite terminal emulator, but it’ll do most of the commandline stuff we all inevitably end up doing. If you use a lot of interactive programs then Eshell is probably not very useful, as it has to spawn a separate term instance for every visual program you run.

Eshell has TRAMP support, custom pseudo-devices, a pocket-sized elisp REPL and lots of useful utility commands like being able to find-file or dired any directory or file you’re in, and that makes it a trusty tool in my toolbox.

59 Comments
  1. llahwehttam permalink

    I really appreciate this blog. You’ve made me more productive already :)

    Regarding globbing, I’ve noticed that globbing is unsorted by default, which has been a bit of a hassle for me.

    echo test_?_???.xml

    vs

    echo (sort (eshell-extended-glob "test_?_???.xml") 'string<)

    Of course, the eshell ‘ls’ command does sort the output, which in some way masks the issue.

    • mickey permalink

      That’s peculiar. I can’t seem to reproduce that on my machine.

      Of course, if it is a problem, you can use the argument modifier (:o) to sort a list.

      • llahwehttam permalink

        My use case is in a directory with a great deal of history, so there’s no telling the order of the directory entries. Nonetheless, echo test_?_???.xml(:o) works quite well.

        Thanks!

  2. It took me a while to figure out for loops in eshell. Here are a few examples:

    • Thanks for this. I use a lot of for loops in my daily bash hacking but am moving more and more towards an emacs centric perspective for everything I do!

  3. Great article! Just wanted to point out a few things:

    1. If you enable the optional “rebind” module, then all the interactive keybinding you’re familiar with in Bash will be available at the Eshell prompt: C-r, C-s, C-w, C-u, etc. The behavior of C-r here is perhaps similar to the new comint functionality you mentioned.

    2. eshell/X is always preferred to a native binary X.

    3. You didn’t mention >>> redirection, which inserts at point. >> inserts at the end of the buffer.

    4. All I/O in Eshell must passt through a buffer. This is why devices can’t be read/written directly. It also means that bulk I/O in Eshell is orders of magnitude slower than a regular shell. It should really only be used for interactive use.

    5. Putting & at the end of a command backgrounds it, if the command executed is external. But there is no job control.

    6. Full Zsh globbing syntax is supported, like **/*.c.

    John (Eshell author)

    • mickey permalink

      John,

      Seems akismet ate your comment – sorry. Thanks for your feedback (and for making Eshell a possibility), I’ll update the article to reflect your changes. Thanks!

      -Mickey.

    • Ingolf Jandt permalink

      > “6. Full Zsh globbing syntax is supported, like **/*.c.”

      Unfortunately eshell hands over the globbing string if nothing matches. This can be worked around by adding a predicate, i.e. “**/*.c(.)”, but IMHO this is a design flaw. Opinions?

      (zsh reports an error if nothing matches, I am not sure this is the right thing to do either, but it prevents obscure errors.)

    • all IO going through buffers: is it really necessary? I tend to do a lot of sort+awk in my daily interactive shell usage – that’s pretty much all I do outside of emacs ;) I like the concept of eshell, but because of the slowness I never manage to use it for real work.

      • mickey permalink

        You should check out my article on sorting in Emacs; you might be surprised to learn that Emacs has excellent and regexp-aware sorting mechanisms.

        As for IO through buffers: that’s pretty much how Emacs does the bulk of its communications. As it goes, Emacs has thousands of commands for operating on buffers but few that operate on internal data structures, like strings, as it would unnecessarily duplicate the functionality already available to a near-infinite-length buffer.

  4. Nice post! Nice blog!

    I find in eshell, when I run a command and redirect output to a file, both stdout and stderr are redirected. I would expect only stdout to be redirected, and stderr to be shown in the shell. But I can’t find any way to make it work that way.

    So for example,

    path/to/my/script > /path/to/my/file

    will write *both* stdout and stderr to file. There’s no way to see stderr in the shell!

    Thanks for the highly detailed original post. I’m curious if you or anyone know how to solve this stderr problem.

    -Dave

    • mickey permalink

      You could try doing it with 1> and 2>. They should redirect stdout and stderr specifically.

      • Dave Cohen permalink

        No luck. Seems to treat 1> exactly the same as >. 2> seems to have no effect.

        I’m using a build of emacs 24.0.50.1 on arch linux. It’s a dev build, might have a bug not present in other versions.

        • Lukas permalink

          I have the same issue with Emacs 23.1.2 on Fedora.

  5. One irritating thing about eshell, hitting C-a at the prompt does not take you to the beginning of your input, but instead goes all the way to the beginning of the shell prompt text. Useless!

  6. Phil permalink

    Thanks mickey, that was excellent. Perhaps GNU should adopt it for the official documentation :)

  7. Leo permalink

    Thanks to mickey for sharing so many tips on using ESHELL. I have discovered many new things here. Thanks.

    I have one bug that is really annoying but I personally don’t know how to fix.

    It can be reproduced following these simple steps:

    1. Emacs -q
    2. M-x eshell
    3. cd /usr/include
    4. ack time

    After about 5 seconds, I see colours completely mixed up like this http://i.imgur.com/Dg3VH.png even the ESHELL prompt is in that disgusting colour.

    Anyone has any idea how to fix that?

    I have tried at least twice to fix it myself but unfortunately due to the asynchronous nature of the process filter I alway gave up in the end. The closest workaround I have found is:

    (defadvice eshell-handle-ansi-color (around test activate)
    “Handle ANSI color codes.”
    (ansi-color-apply-on-region (1- eshell-last-output-start)
    (1- eshell-last-output-end)))

    Leo

    • mickey permalink

      Hmm. That stuff is always fiddly to deal with. I think the easiest is to make an elisp eshell command called eshell/ack and have it intercept the command and display the output in its own buffer. Look at how eshell/grep and eshell-grep is implemented.

      • Leo permalink

        Thanks for your prompt reply. Sorry it seems ‘ack’ caught your attention. I only used it to demonstrate the problem.

  8. One thing I found lacking in eshell was the find utility. But found it in the find-lisp library — find-lisp-find-files and find-lisp-find-dired (which could be aliased to find if desired). Unfortunate about the missing input redirection, but otherwise eshell is complete for my purposes!

  9. brad clawsie permalink

    great article! it is frustrating to find good eshell docs.

  10. danlei permalink

    What an excellent article — Thanks a million!

    Although I’ve been using Eshell on a regular basis, it’d never have occured to me that all those nifty zsh predicates/modifiers are working in eshell. The redirection features seem pretty nice too.

  11. Eugene permalink

    I am willing to user eshell instead of shell but I would like to know better how to customize my eshell-prompt especially to remain with ~ instead of the full path. Thanks.

  12. Very nice article.

    One thing that’s continually kept me from adopting eshell is that I work almost exclusively over Tramp, and every time I pass eshell a non-built-in command, it takes a few seconds to open the connection before I get my result.

    With M-x shell, the connection is opened once at the beginning of the session, and all subsequent commands execute immediately. Does anyone have any experience with this or know of any workarounds?

  13. Lukas permalink

    I never knew eshell could do all these cool things, thanks!

    One question though: In Bash, I use Alt+. all the time to cycle through the last argument of previous commands. Is there anything like it for eshell?

    I read that the $_ variable gives me the last argument of the previous command but that’s only a small subset of what Alt+. in Bash does.

    Lukas

  14. Mathias Dahl permalink

    There is also a great deal of information about Eshell over at EmacsWiki: http://www.emacswiki.org/emacs/CategoryEshell

  15. This is maybe more of an Elisp question than an Eshell question, but having the full path in the eshell prompt is driving me nuts. There are some decent examples of changing your eshell prompt, but how do I chop off all of the directories which are parents of the CWD? Instead of /home/me/Sandbox/repo1/proj5/src/foo $ as my prompt I just want foo $

    Thanks

  16. One more thought then I’ll stop spamming your blog with comments:
    I find the KDE file browser option to include a terminal in a pane below the current directory really nice, as I navigate with the gui file manager the terminal automagically cd’s to the CWD. Anybody know of any packages, or have thoughts on the difficulty of emulating this behaviour between an eshell buffer and a dired buffer? (This option is available in Konqueror as of at least KDE 3.5.x and also dolphin in KDE 4.x. An extension can be added to the gnome file browser, nautilus to also enable this functionality.)

  17. Just a little detail (a possible typo). In the part about how one can output to a symbol, I think it should be “echo $(cadr myvar)” instead of “echo $(cadr foo)”.

    Thanks a bunch for this great article!

  18. Anonymous permalink

    Just to point out a small typo.

    When you said:
    “You must switch to the Eshell buffer and type M-: (shell-smart-initialize)”

    you probably meant “M-: (eshell-smart-initialize)” right?

  19. SomeOne permalink

    Superb article — brilliant introduction to Eshell.

    I have replace most of my Cygwin usage, was facing exactly the same problems as you mentioned.

  20. alias cp ‘cp -i $*’ doesn’t work for me. When I define this alias I get “cp: missing destination file or directory”. I’m using emacs 23.3.

  21. LongList permalink

    Does eshell have anything similar to dired’s

    (setq ls-lisp-verbosity nil)

    to remove the uid and gid columns from
    “ls -l” long-form directory listings?

    (Emacs 24.0.92.1)

    And yes, thanks for a terrific guide!

  22. Tassilo Horn permalink

    Nice post. I’m just giving eshell a try, and so far I like it. Especially since I don’t need to omit “visual” commands like top, which used to keep me away from emacs internal shells. (I don’t like M-x term. I can’t cope with its bindings…

    Now there’re just a few things left to make me really enjoy eshell for all my cmd line needs:

    1. How can I teach it to show things like “git log” or “bzr log” also in a term?

    2. How can I configure this command interception?

    • mickey permalink

      Hi Tassilo,

      1. You can tweak the list variable eshell-visual-commands

      2. As for configuring it, you can try the customize group M-x customize-group RET eshell-term RET

      Thanks.

      • Tassilo Horn permalink

        1. The problem is that eshell-visual-commands have to be plain commands whereas “git log” is a command with one argument (subcommand). Adding “git log” to the list has no effect.

        2. No, I’ve meant how to configure the *interception* feature. M-x apropos-variable doesn’t find any variable, M-x apropos finds the function eshell-intercept-command, but that doesn’t really help me. How can I add other commands to be intercepted and their output being shown in emacs itself?

  23. Matt Ford permalink

    Hi, I had some trouble with recent emacs getting the smart shell stuff to initialise, a recent patch looks to have taken all the initialize function calls out of eshell hooks. Perhaps it all now works in a different way but I couldn’t see how.

    I got it loaded with your additions plus

    (add-hook ‘eshell-mode-hook ‘eshell-smart-initialize)

    Nice post!

Trackbacks & Pingbacks

  1. Tweets that mention A Complete Guide to Mastering Eshell | Mastering Emacs -- Topsy.com
  2. Running Shells in Emacs: An Overview | Mastering Emacs
  3. Emacs « Cootcraig's Blog
  4. eshell – 따라쟁이
  5. What’s New In Emacs 24 (part 1) | Mastering Emacs
  6. 迁移Emacs笔记 | Gossip Coder
  7. Playing with Eshell — The Endeavour
  8. PComplete: Context-Sensitive Completion in Emacs | Mastering Emacs
  9. Eshell | Irreal
  10. Eshell completion for git, bzr, and hg | Tassilo's Blog
  11. Open Emacs dired buffer from shell | fortune datko

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS