diff options
| -rw-r--r-- | lisp/appearance/modeline.el | 6 | ||||
| -rw-r--r-- | lisp/shell.el | 25 |
2 files changed, 25 insertions, 6 deletions
diff --git a/lisp/appearance/modeline.el b/lisp/appearance/modeline.el index 4fa1710..9dde6c6 100644 --- a/lisp/appearance/modeline.el +++ b/lisp/appearance/modeline.el @@ -76,6 +76,12 @@ RIGHT aligned respectively." "/" (number-to-string (pdf-cache-number-of-pages)) "]")) + ((and (eq major-mode 'shell-mode) (boundp 'shell-title)) + (concat "%b [%m: " + shell-title + "] [%*] Ln: %l/" + (number-to-string (1+ (count-lines 1 (point-max)))) + " Col: %c")) (t (concat "%b [%m] [%*] Ln: %l/" (number-to-string (1+ (count-lines 1 (point-max)))) diff --git a/lisp/shell.el b/lisp/shell.el index 843f51e..1b42c19 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -89,6 +89,18 @@ (remove 'ansi-color-process-output comint-output-filter-functions)) + :init + (defun xterm-title-filter (string) + "Pre-match filter for setting a buffer-local variable +`shell-title' upon reading the ANSI escape sequence for setting +the terminal emulator's window title." + (let ((pattern (rx "\033]0;" + (group-n 1 (one-or-more (not "\007"))) + "\007"))) + (when (string-match pattern string) + (setq-local shell-title (match-string 1 string)))) + string) + :hook (shell-mode . (lambda () @@ -97,7 +109,8 @@ ;; Prevent font-locking from being re-enabled in this buffer (make-local-variable 'font-lock-function) (setq font-lock-function (lambda (_) nil)) - (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter nil t)))) + (add-hook 'comint-preoutput-filter-functions 'xterm-color-filter nil t) + (add-hook 'comint-preoutput-filter-functions 'xterm-title-filter nil t)))) @@ -129,9 +142,9 @@ (let* ((pmark (process-mark proc)) (intxt (if (>= (point) (marker-position pmark)) (progn (if comint-eol-on-send - (if comint-use-prompt-regexp - (end-of-line) - (goto-char (field-end)))) + (if comint-use-prompt-regexp + (end-of-line) + (goto-char (field-end)))) (buffer-substring pmark (point))) (let ((copy (funcall comint-get-old-input))) (goto-char pmark) @@ -147,7 +160,7 @@ (args (cl-rest (split-string input " "))) (visual (cl-member command visual-commands :test #'string=))) (cond ((string= command "man") (man (string-join args " ")) - (shell-fake-comint-send pmark)) + (shell-fake-comint-send pmark)) (visual (start-process "" nil "alacritty" "--class" (format "*%s*,*%s*" command command) @@ -187,6 +200,6 @@ Kills the buffer when the shell program quits." (defun add-shell-sentinel (&rest args) (ignore args) (set-process-sentinel (get-buffer-process (current-buffer)) - #'shell-kill-buffer-on-quit)) + #'shell-kill-buffer-on-quit)) (add-hook 'shell-mode-hook #'add-shell-sentinel) |