Emacs: M-x 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 How to 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. Emacs: Run Shell in Emacs
  2. Why Run Shell in Emacs?
  3. Emacs: Difference between shell, term, eshell
  4. Emacs: M-x eshell
  5. Emacs: View Linux man Page
  6. Emacs: Interactive Abbrev
  7. Emacs: File Manager, dired
  8. Emacs: Batch Rename Files
  9. Linux: Basic Shell Commands
Like it? Buy Xah Emacs Tutorial. Thanks.