Function: shell-narrow-to-prompt

shell-narrow-to-prompt is an interactive and byte-compiled function defined in shell.el.gz.

Signature

(shell-narrow-to-prompt)

Documentation

Narrow buffer to the command line (and any following command output) at point.

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/shell.el.gz
(defun shell-narrow-to-prompt ()
  "Narrow buffer to the command line (and any following command output) at point."
  (interactive)
  (let ((begin (shell--prompt-begin-position)))
    (narrow-to-region
     begin
     (save-excursion
       (goto-char (shell--prompt-end-position))
       (call-interactively #'comint-next-prompt)
       (if (= begin (shell--prompt-begin-position))
           (point-max)
         (shell--prompt-begin-position))))))