File: sh-script.el.html

Major mode for editing shell scripts. Bourne, C and rc shells as well as various derivatives are supported and easily derived from. Structured statements can be inserted with one command or abbrev. Completion is available for filenames, variables known from the script, the shell and the environment as well as commands.

A Flymake backend using the "shellcheck" program is provided. See https://www.shellcheck.net/ for installation instructions.

Defined variables (77)

bash-ts-mode-abbrev-tableAbbrev table for ‘bash-ts-mode’.
bash-ts-mode-hookHook run after entering ‘bash-ts-mode’.
bash-ts-mode-mapKeymap for ‘bash-ts-mode’.
sh-alias-alistAlist for transforming shell names to what they really are.
sh-ancestor-alistAlist showing the direct ancestor of various shells.
sh-assignment-regexpRegexp for the variable name and what may follow in an assignment.
sh-backslash-alignIf non-nil, ‘sh-backslash-region’ will align backslashes.
sh-backslash-columnColumn in which ‘sh-backslash-region’ inserts backslashes.
sh-base-mode-abbrev-tableAbbrev table for ‘sh-base-mode’.
sh-base-mode-hookHook run after entering ‘sh-base-mode’.
sh-base-mode-mapKeymap for ‘sh-base-mode’.
sh-base-mode-syntax-tableSyntax table for ‘sh-base-mode’.
sh-basic-offsetThe default indentation increment.
sh-beginning-of-commandRegexp to determine the beginning of a shell command.
sh-builtinsList of all shell builtins for completing read and fontification.
sh-debugEnable lots of debug messages - if function ‘sh-debug’ is enabled.
sh-dynamic-complete-functionsFunctions for doing TAB dynamic completion.
sh-electric-here-document-modeNon-nil if Sh-Electric-Here-Document mode is enabled.
sh-electric-here-document-mode-hookHook run after entering or leaving ‘sh-electric-here-document-mode’.
sh-end-of-commandRegexp to determine the end of a shell command.
sh-font-lock-keywords-varDefault expressions to highlight in Shell Script modes. See ‘sh-feature’.
sh-font-lock-keywords-var-1Subdued level highlighting for Shell Script modes.
sh-font-lock-keywords-var-2Gaudy level highlighting for Shell Script modes.
sh-header-markerWhen non-nil is the end of header for prepending by M-x sh-execute-region.
sh-here-document-wordWord to delimit here documents.
sh-imenu-generic-expressionAlist of regular expressions for recognizing shell function definitions.
sh-indent-after-caseHow much to indent a statement relative to the ‘case’ statement.
sh-indent-after-continuationIf non-nil, indent relative to the continued line’s beginning.
sh-indent-after-doHow much to indent a line after a ‘do’ statement.
sh-indent-after-doneHow much to indent a statement after a ‘done’ keyword.
sh-indent-after-elseHow much to indent a statement after an ‘else’ statement.
sh-indent-after-functionHow much to indent after a function line.
sh-indent-after-ifHow much to indent a statement after an ‘if’ statement.
sh-indent-after-loop-constructHow much to indent a statement after a loop construct.
sh-indent-after-openHow much to indent after a line with an opening parenthesis or brace.
sh-indent-after-switchHow much to indent a ‘case’ statement relative to the ‘switch’ statement.
sh-indent-for-case-altHow much to indent statements after the case label.
sh-indent-for-case-labelHow much to indent a case label statement.
sh-indent-for-continuationHow much to indent for a continuation statement.
sh-indent-for-doHow much to indent a ‘do’ statement.
sh-indent-for-doneHow much to indent a ‘done’ relative to its matching stmt. Usually 0.
sh-indent-for-fiHow much to indent a ‘fi’ relative to its ‘if’. Usually 0.
sh-indent-for-thenHow much to indent a ‘then’ relative to its ‘if’.
sh-indent-statement-after-andHow to indent statements following && in Shell-Script mode.
sh-indent-supportedIndentation rule set to use for each shell type.
sh-indent-supported-hereNon-nil if we support indentation for the current buffer’s shell type.
sh-indentationThe default indentation increment.
sh-kws-for-doneWhich keywords can match the word ‘done’ in this shell.
sh-leading-keywordsList of keywords that may be immediately followed by a builtin or keyword.
sh-make-vars-localControls whether indentation variables are local to the buffer.
sh-mode--treesit-declaration-commandsKeywords in declaration commands.
sh-mode--treesit-keywordsMinimal list of keywords that belong to tree-sitter-bash’s grammar.
sh-mode--treesit-operatorsA list of ‘sh-mode’ operators to fontify.
sh-mode--treesit-settingsTree-sitter font-lock settings for ‘sh-mode’.
sh-mode-abbrev-tableAbbrev table for ‘sh-mode’.
sh-mode-hookHook run by ‘sh-mode’.
sh-mode-mapKeymap used in Shell-Script mode.
sh-mode-menuMenu for Shell-Script mode.
sh-mode-syntax-tableThe syntax table to use for Shell-Script mode.
sh-mode-syntax-table-inputSyntax-table used in Shell-Script mode. See ‘sh-feature’.
sh-other-keywordsList of keywords not in ‘sh-leading-keywords’.
sh-regexp-for-doneA buffer-local regexp to match opening keyword for done.
sh-remember-variable-minDon’t remember variables less than this length for completing reads.
sh-set-shell-hookHook run by ‘sh-set-shell’.
sh-shellThe shell being programmed. This is set by M-x sh-set-shell.
sh-shell-argSingle argument string for the magic number. See ‘sh-feature’.
sh-shell-fileThe executable file name for the shell being programmed.
sh-shell-processThe inferior shell process for interaction.
sh-shell-variablesAlist of shell variable names that should be included in completion.
sh-shell-variables-initializedNon-nil if ‘sh-shell-variables’ is initialized.
sh-shellcheck-argumentsAdditional arguments to the shellcheck program.
sh-shellcheck-programName of the shellcheck executable.
sh-skeleton-pair-default-alistValue to use for ‘skeleton-pair-default-alist’ in Shell-Script mode.
sh-styles-alistA list of all known shell indentation styles.
sh-testInitial input in Bourne if, while and until skeletons. See ‘sh-feature’.
sh-var-listA list of variables used by script mode to control indentation.
sh-variablesList of all shell variables available for completing read.

Defined functions (79)

bash-ts-mode()
sh--cmd-completion-table-gen(STRING)
sh--guess-shell()
sh--inside-noncommand-expression(POS)
sh--redirect-bash-ts-mode(OLDFN)
sh-add(VAR DELTA)
sh-add-completer(STRING PREDICATE CODE)
sh-append(ANCESTOR &rest LIST)
sh-append-backslash(COLUMN)
sh-assignment(ARG)
sh-backslash-region(FROM TO DELETE-FLAG)
sh-base-mode()
sh-basic-indent-line()
sh-beginning-of-command()
sh-canonicalize-shell(SHELL)
sh-case(&optional STR ARG)
sh-cd-here()
sh-current-defun-name()
sh-debug(&rest ARGS)
sh-electric-here-document-mode(&optional ARG)
sh-end-of-command()
sh-execute-region(START END &optional FLAG)
sh-feature(ALIST &optional FUNCTION)
sh-font-lock-keywords(&optional KEYWORDS)
sh-font-lock-keywords-1(&optional BUILTINS)
sh-font-lock-keywords-2()
sh-font-lock-open-heredoc(START STRING EOL)
sh-font-lock-paren(START)
sh-font-lock-quoted-subshell(LIMIT)
sh-font-lock-syntactic-face-function(STATE)
sh-for(&optional STR ARG)
sh-function(&optional STR ARG)
sh-if(&optional STR ARG)
sh-in-comment-or-string(START)
sh-indexed-loop(&optional STR ARG)
sh-is-quoted-p(POS)
sh-learn-buffer-indent()
sh-learn-line-indent()
sh-load-style(NAME)
sh-make-vars-local()
sh-mkword-regexpr(WORD)
sh-mode()
sh-mode--treesit-other-keywords()
sh-mode-menu(ARG1)
sh-mode-syntax-table(TABLE &rest LIST)
sh-modify(SKELETON &rest LIST)
sh-name-style(NAME &optional CONFIRM-OVERWRITE)
sh-quoted-p()
sh-remember-variable(VAR)
sh-repeat(&optional STR ARG)
sh-reset-indent-vars-to-global-values()
sh-save-styles-to-buffer(BUFF)
sh-select(&optional STR ARG)
sh-send-line-or-region-and-step()
sh-send-text(TEXT)
sh-set-indent()
sh-set-shell(SHELL &optional NO-QUERY-FLAG INSERT-FLAG)
sh-shell-initialize-variables()
sh-shell-process(FORCE)
sh-shellcheck-flymake(REPORT-FN &rest ARGS)
sh-show-indent(&optional ARG)
sh-show-shell()
sh-smie--continuation-start-indent()
sh-smie--keyword-p()
sh-smie--newline-semi-p(&optional TOK)
sh-smie--rc-after-special-arg-p()
sh-smie--rc-newline-semi-p()
sh-smie--sh-keyword-in/do-p(TOK)
sh-smie--sh-keyword-p(TOK)
sh-smie-rc-rules(KIND TOKEN)
sh-smie-sh-rules(KIND TOKEN)
sh-syntax-propertize-function(START END)
sh-syntax-propertize-here-doc(END)
sh-tmp-file(&optional STR ARG)
sh-until(&optional STR ARG)
sh-var-value(VAR &optional IGNORE-ERROR)
sh-while(&optional STR ARG)
sh-while-getopts(&optional STR ARG)
shell-script-mode()

Defined faces (3)

sh-escaped-newlineFace used for (non-escaped) backslash at end of a line in Shell-script mode.
sh-heredocFace to show a here-document.
sh-quoted-execFace to show quoted execs like `blabla`.