Emacs: eshell

By Xah Lee. Date: . Last updated: .

eshell is a shell written entirely in emacs lisp.

emacs eshell 2014-10-18
emacs M-x eshell

What's eshell? how's it different from shell?

eshell is similar in purpose to unix's bash.

eshell is written entirely in elisp.

eshell supports most linux commands such as {cd, ls, cp, mkdir, …}.

One major advantage of eshell is that you can run basic linux commands in Microsoft Windows, without installing unix software such as Cygwin. [see Installing Cygwin Tutorial]

See also: Emacs: Difference between shell, term, eshell

Advantages of Eshell Over a Regular Shell

[From NikkiA at reddit]

eshell Documentation


Eshell is written by John Wiegley. Thank you John.

How to set environment variable FOR eshell?

you can get and set environment variables for emacs use only by:

; show env var named path
(getenv "PATH")

; example of setting env var named “path”
; by prepending new paths to existing paths
(setenv "PATH"
   "C:/cygwin/usr/local/bin" ";"
   "C:/cygwin/usr/bin" ";"
   "C:/cygwin/bin" ";"
   (getenv "PATH") ; inherited from OS

Put in your emacs init file. Restart emacs, or, select the code then call eval-region. [see Evaluate Emacs Lisp Code]

This will effect environment variable within emacs only. It won't change the real environment variables used by OS.

When you call a command such as ruby irb that's not in eshell, eshell will try to find it in the env var PATH.

Also, emacs do inherit your environment variable PATH from OS. For detail, see: Emacs in Microsoft Windows FAQ.

eshell Pains

Note: eshell is similar to bash, but is not bash.

Complicated bash/shell commands involving pipe or escape may not work in eshell, or need modification.

See Emacs: eshell pains

I recommend shell if you are beginner.

Use eshell only for simple routine commands, or if you are emacs expert.

See also: Emacs Shell in Movie TRON

Shell Topic

  1. Run Shell in Emacs
  2. Why Run Shell in Emacs?
  3. Difference between shell, term, eshell
  4. eshell
  5. View Linux man Page
  6. Interactive Abbrev
  7. File Manager, dired
  8. Batch Rename Files
  9. Linux: Basic Shell Commands

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs


Emacs Lisp