Variable: shell-mode-abbrev-table
shell-mode-abbrev-table is a variable defined in shell.el.gz.
Value
#<obarray n=1>
Documentation
Abbrev table for shell-mode.
Source Code
;; Defined in /usr/src/emacs/lisp/shell.el.gz
(define-derived-mode shell-mode comint-mode "Shell"
"Major mode for interacting with an inferior shell.
\\<shell-mode-map>
\\[comint-send-input] after the end of the process' output sends the text from
the end of process to the end of the current line.
\\[comint-send-input] before end of process output copies the current line minus the prompt to
the end of the buffer and sends it (\\[comint-copy-old-input] just copies the current line).
\\[comint-send-invisible] reads a line of text without echoing it, and sends it to
the shell. This is useful for entering passwords. Or, add the function
`comint-watch-for-password-prompt' to `comint-output-filter-functions'.
If you want to make multiple shell buffers, rename the \"*shell*\" buffer
using \\[rename-buffer] or \\[rename-uniquely] and start a new shell.
If you want to make shell buffers limited in length, add the function
`comint-truncate-buffer' to `comint-output-filter-functions'.
If you accidentally suspend your process, use \\[comint-continue-subjob]
to continue it.
`cd', `pushd' and `popd' commands given to the shell are watched by Emacs to
keep this buffer's default directory the same as the shell's working directory.
While directory tracking is enabled, the shell's working directory is displayed
by \\[list-buffers] or \\[mouse-buffer-menu] in the `File' field.
\\[dirs] queries the shell and resyncs Emacs's idea of what the current
directory stack is.
\\[shell-dirtrack-mode] turns directory tracking on and off.
\(The `dirtrack' package provides an alternative implementation of this
feature - see the function `dirtrack-mode'.)
\\{shell-mode-map}
Customization: Entry to this mode runs the hooks on `comint-mode-hook' and
`shell-mode-hook' (in that order). Before each input, the hooks on
`comint-input-filter-functions' are run. After each shell output, the hooks
on `comint-output-filter-functions' are run.
Variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp'
and `shell-popd-regexp' are used to match their respective commands,
while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique'
control the behavior of the relevant command.
Variables `comint-completion-autolist', `comint-completion-addsuffix',
`comint-completion-recexact' and `comint-completion-fignore' control the
behavior of file name, command name and variable name completion. Variable
`shell-completion-execonly' controls the behavior of command name completion.
Variable `shell-completion-fignore' is used to initialize the value of
`comint-completion-fignore'.
Variables `comint-input-ring-file-name' and `comint-input-autoexpand' control
the initialization of the input ring history, and history expansion.
Variables `comint-output-filter-functions', a hook, and
`comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output'
control whether input and output cause the window to scroll to the end of the
buffer.
By default, shell mode does nothing special when it receives a
\"bell\" character (C-g or ^G). If you
(add-hook \\='comint-output-filter-functions #\\='shell-filter-ring-bell nil t)
from `shell-mode-hook', Emacs will call the `ding' function
whenever it receives the bell character in output from a
command."
:interactive nil
:after-hook
(unless comint-use-prompt-regexp
(if shell-fontify-input-enable
(comint-fontify-input-mode))
(if shell-highlight-undef-enable
(shell-highlight-undef-mode)))
(setq comint-prompt-regexp shell-prompt-pattern)
(shell-completion-vars)
(setq-local paragraph-separate "\\'")
(setq-local paragraph-start comint-prompt-regexp)
(setq-local font-lock-defaults '(shell-font-lock-keywords t))
(setq-local bookmark-make-record-function #'shell-bookmark-make-record)
(setq-local shell-dirstack nil)
(setq-local shell-last-dir nil)
(setq-local comint-get-old-input #'shell-get-old-input)
;; People expect Shell mode to keep the last line of output at
;; window bottom.
(setq-local scroll-conservatively 101)
(shell-dirtrack-mode 1)
;; By default, ansi-color applies faces using overlays. This is
;; very inefficient in Shell buffers (e.g. Bug#10835). We use a
;; custom `ansi-color-apply-face-function' to convert color escape
;; sequences into `font-lock-face' properties.
(setq-local ansi-color-apply-face-function #'shell-apply-ansi-color)
(shell-reapply-ansi-color)
(add-hook 'comint-indirect-setup-hook
#'shell-indirect-setup-hook 'append t)
(setq comint-indirect-setup-function
(let ((shell shell--start-prog))
(lambda ()
(require 'sh-script)
(cl-letf
(((default-value 'sh-shell-file)
(or shell sh-shell-file))
(inhibit-message t)
(message-log-max nil))
(sh-mode)))))
(setq-local indent-line-function #'comint-indent-input-line-default)
(setq-local indent-region-function
#'comint-indent-input-region-default)
;; This is not really correct, since the shell buffer does not really
;; edit this directory. But it is useful in the buffer list and menus.
(setq list-buffers-directory (expand-file-name default-directory))
;; shell-dependent assignments.
(when (ring-empty-p comint-input-ring)
(let* ((remote (file-remote-p default-directory))
(shell (or shell--start-prog ""))
(hfile (cond ((stringp shell-history-file-name)
shell-history-file-name)
((null shell-history-file-name)
(if remote
(shell-command-to-string "echo -n $HISTFILE")
(getenv "HISTFILE")))))
hsize)
(and (string-equal hfile "") (setq hfile nil))
(when (and (not remote) (not hfile))
(setq hfile
(cond ((string-equal shell "bash") "~/.bash_history")
((string-equal shell "ksh") "~/.sh_history")
((string-equal shell "zsh") "~/.zsh_history")
(t "~/.history"))))
(when (stringp hfile)
(setq hsize
(if remote
(shell-command-to-string "echo -n $HISTSIZE")
(getenv "HISTSIZE")))
(and (stringp hsize)
(integerp (setq hsize (string-to-number hsize)))
(> hsize 0)
(setq-local comint-input-ring-size hsize))
(setq comint-input-ring-file-name
(concat remote hfile)))
(if (and comint-input-ring-file-name
(or (equal comint-input-ring-file-name "")
(equal (file-truename comint-input-ring-file-name)
(file-truename null-device))))
(setq comint-input-ring-file-name nil))
;; Arrange to write out the input ring on exit, if the shell doesn't
;; do this itself.
(if (and comint-input-ring-file-name
(string-match shell-dumb-shell-regexp shell))
(set-process-sentinel (get-buffer-process (current-buffer))
#'shell-write-history-on-exit))
(setq shell-dirstack-query
(cond ((string-equal shell "sh") "pwd")
((string-equal shell "ksh") "echo $PWD ~-")
;; Bypass any aliases. TODO all shells could use this.
((string-equal shell "bash") "command dirs")
((and (string-equal shell "bash.exe")
(eq system-type 'windows-nt)
(eq (w32-application-type (executable-find "bash.exe"))
'msys))
"command pwd -W")
((string-equal shell "zsh") "dirs -l")
(t "dirs")))
;; Bypass a bug in certain versions of bash.
(when (string-equal shell "bash")
(add-hook 'comint-preoutput-filter-functions
#'shell-filter-ctrl-a-ctrl-b nil t))
;; Skip extended history for zsh.
(when (string-equal shell "zsh")
(setq-local comint-input-ring-file-prefix
": [[:digit:]]+:[[:digit:]]+;")))
(comint-read-input-ring t)))