HomeMathComputingArtsWordsLiteratureMusictwitter facebook webfeed

Emacs: What's eshell? “eshell” vs “shell” Difference?

Advertise Here For Profit

Xah Lee, 2010-10-09, 2011-01

I've always thought that eshell was just a toy, and never really tried to use it other than knowning it's written entirely in elisp. But over the past few years i learned from emacs community, that apparently many people do use it. Also, because eshell is written in emacs lisp, that means you can enter elisp code or call any of the 3000+ elisp commands or functions directly in the eshell command line.

For example, try typing (+ 3 4) in the prompt, and it returns “7”.

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

eshell is written entirely in elisp.

Practically speaking, that means when you are on Windows and don't have Cygwin installed, you can still use all the common unix ls, cd, mkdir, cp, grep, … stuff, in eshell.

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"
  (concat
   "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”.

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 “perl” that's not in eshell, eshell will try to find it in the env var PATH. Also, emacs do inherit your PATH environment variable from OS. For detail, see: Emacs and Microsoft Windows Tips.

Advantages of Eshell Over a Regular Shell

NikkiA at reddit gave some very useful tips:

Here's a more in-depth tutorial about eshell. Mastering Eshell by Mickey @ Source www.masteringemacs.org

Eshell is written by John Wiegley. Thanks John.

blog comments powered by Disqus