Function: eshell-mode
eshell-mode is an autoloaded, interactive and byte-compiled function
defined in esh-mode.el.gz.
Signature
(eshell-mode)
Documentation
Emacs shell interactive mode.
This mode runs the hook eshell-mode-hook, as the final or
penultimate step during initialization.
C-M-l eshell-show-output
C-a eshell-bol
C-c C-a eshell-bol
C-c C-b eshell-backward-argument
C-c C-e eshell-show-maximum-output
C-c C-f eshell-forward-argument
C-c C-o eshell-kill-output
C-c C-r eshell-show-output
C-c C-t eshell-truncate-buffer
C-c C-u eshell-kill-input
C-c C-w backward-kill-word
C-c C-y eshell-repeat-argument
C-c M-d eshell-toggle-direct-send
C-c M-o eshell-mark-output
C-c RET eshell-copy-old-input
M-RET eshell-queue-input
RET eshell-send-input
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-mode.el.gz
;;;###autoload
(define-derived-mode eshell-mode fundamental-mode "Eshell"
"Emacs shell interactive mode."
(setq-local eshell-mode t)
(when (and eshell-status-in-mode-line
(listp mode-line-format))
(make-local-variable 'eshell-command-running-string)
(let ((fmt (copy-sequence mode-line-format)))
(setq-local mode-line-format fmt))
(let ((mode-line-elt (cdr (memq 'mode-line-front-space mode-line-format))))
(if mode-line-elt
(setcar mode-line-elt 'eshell-command-running-string))))
(setq-local bookmark-make-record-function #'eshell-bookmark-make-record)
(setq local-abbrev-table eshell-mode-abbrev-table)
(setq-local window-point-insertion-type t)
(setq-local list-buffers-directory (expand-file-name default-directory))
;; always set the tab width to 8 in Eshell buffers, since external
;; commands which do their own formatting almost always expect this
(setq-local tab-width 8)
;; don't ever use auto-fill in Eshell buffers
(setq auto-fill-function nil)
;; always display everything from a return value
(setq-local print-length nil)
(setq-local print-level nil)
;; set require-final-newline to nil; otherwise, all redirected
;; output will end with a newline, whether or not the source
;; indicated it!
(setq-local require-final-newline nil)
(setq-local max-lisp-eval-depth (max 3000 max-lisp-eval-depth))
(setq-local eshell-last-input-start (point-marker))
(setq-local eshell-last-input-end (point-marker))
(setq-local eshell-last-output-start (point-marker))
(setq-local eshell-last-output-end (point-marker))
(setq-local eshell-last-output-block-begin (point))
(let ((modules-list (copy-sequence eshell-modules-list)))
(setq-local eshell-modules-list modules-list))
;; This is to avoid making the paragraph base direction
;; right-to-left if the first word just happens to start with a
;; strong R2L character.
(setq bidi-paragraph-direction 'left-to-right)
;; load extension modules into memory. This will cause any global
;; variables they define to be visible, since some of the core
;; modules sometimes take advantage of their functionality if used.
(dolist (module eshell-modules-list)
(let ((module-fullname (symbol-name module))
module-shortname)
(if (string-match "^eshell-\\(.*\\)" module-fullname)
(setq module-shortname
(concat "em-" (match-string 1 module-fullname))))
(unless module-shortname
(error "Invalid Eshell module name: %s" module-fullname))
(unless (featurep (intern module-shortname))
(condition-case nil
(load module-shortname)
(error (lwarn 'eshell :error
"Unable to load module `%s' (defined in `eshell-modules-list')"
module-fullname))))))
(unless (file-exists-p eshell-directory-name)
(eshell-make-private-directory eshell-directory-name t))
;; Load core Eshell modules, then extension modules, for this session.
(dolist (module (append (eshell-subgroups 'eshell) eshell-modules-list))
(let ((load-hook (intern-soft (format "%s-load-hook" module)))
(initfunc (intern-soft (format "%s-initialize" module))))
(when (and load-hook (boundp load-hook))
(if (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
(run-hooks load-hook))
;; So we don't need the -initialize functions on the hooks (bug#5375).
(and initfunc (fboundp initfunc) (funcall initfunc))))
(if eshell-send-direct-to-subprocesses
(add-hook 'pre-command-hook #'eshell-intercept-commands t t))
(if eshell-scroll-to-bottom-on-input
(add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
(when eshell-scroll-show-maximum-output
(setq-local scroll-conservatively 1000))
(when eshell-status-in-mode-line
(add-hook 'eshell-pre-command-hook #'eshell-command-started nil t)
(add-hook 'eshell-post-command-hook #'eshell-command-finished nil t))
(add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t)
(if eshell-first-time-p
(run-hooks 'eshell-first-time-mode-hook))
(run-hooks 'eshell-post-command-hook))