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 written entirely in elisp.

One major advantage of eshell is that you can run basic linux commands {grep, cat, …} in Microsoft Windows, without installing unix software such as Cygwin. 〔➤see Installing Cygwin Tutorial

See also: Emacs: What's the difference between {shell, term, ansi-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 and Microsoft Windows Tips.

eshell Tricks

output shell command to buffer

ls > #<buffer ttt>

output shell command to a buffer.

once you did that, you can switch to buffer by calling ido-switch-bufferCtrl+x b

thanks to Gregory Collins.

eshell Pains

Emacs: eshell pains

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from Best Keyboard for Emacs