Eshell: Bind "C-x n d" to eshell-narrow-to-prompt.

master
Pierre Neidhardt 2020-05-09 11:46:49 +02:00
parent d616d21770
commit 9a9a25f764
1 changed files with 23 additions and 0 deletions

View File

@ -304,4 +304,27 @@ This should be faster then `seq-uniq'."
(require 'patch-eshell-inside-emacs)
(defun eshell-narrow-to-prompt ()
"Narrow buffer to prompt at point."
(interactive)
(narrow-to-region
(save-excursion
(forward-line)
(call-interactively #'eshell-previous-prompt)
(beginning-of-line)
(point))
(save-excursion
(forward-line)
(call-interactively #'eshell-next-prompt)
(re-search-backward eshell-prompt-regexp nil t)
(when (and (require 'eshell-prompt-extras nil 'noerror)
(eq eshell-prompt-function #'epe-theme-multiline-with-status))
(previous-line))
(point))))
(defun ambrevar/eshell-set-keys ()
(define-key eshell-mode-map (kbd "C-x n d") 'eshell-narrow-to-prompt))
(add-hook 'eshell-mode-hook 'ambrevar/eshell-set-keys)
(provide 'init-eshell)