Function: bash-ts-mode

bash-ts-mode is an autoloaded, interactive and byte-compiled function defined in sh-script.el.gz.

Signature

(bash-ts-mode)

Documentation

Major mode for editing Bash shell scripts.

This mode automatically falls back to sh-mode if the buffer is not written in Bash or sh.

In addition to any hooks its parent mode sh-base-mode might have run, this mode runs the hook bash-ts-mode-hook, as the final or penultimate step during initialization.

This function has :around advice: sh--redirect-bash-ts-mode.

Probably introduced at or before Emacs version 29.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sh-script.el.gz
;;;###autoload
(define-derived-mode bash-ts-mode sh-base-mode "Bash"
  "Major mode for editing Bash shell scripts.
This mode automatically falls back to `sh-mode' if the buffer is
not written in Bash or sh."
  :syntax-table sh-mode-syntax-table
  (when (treesit-ready-p 'bash)
    (sh-set-shell "bash" nil nil)
    (add-hook 'flymake-diagnostic-functions #'sh-shellcheck-flymake nil t)
    (add-hook 'hack-local-variables-hook
              #'sh-after-hack-local-variables nil t)
    (treesit-parser-create 'bash)
    (setq-local treesit-font-lock-feature-list
                '(( comment function)
                  ( command declaration-command keyword string)
                  ( builtin-variable constant heredoc number
                    string-interpolation variable)
                  ( bracket delimiter misc-punctuation operator)))
    (setq-local treesit-font-lock-settings
                sh-mode--treesit-settings)
    (setq-local treesit-defun-type-regexp "function_definition")
    (treesit-major-mode-setup)))