From de32ffbe0d501f9dc61bc3a8889df3e207459535 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 15 Jun 2026 21:45:49 -0500 Subject: fix(eshell): flatten visual-commands, wire xterm-color correctly - eshell-visual-commands is a flat string list, but add-to-list pushed the whole list as one element, so lf/ranger/htop/top never opened in a visual terminal. dolist the strings instead. (visual-subcommands/options are alists and were already correct.) - The xterm-color before-prompt hook was registered as eshell-before-prompt-hook, which use-package turned into eshell-before-prompt-hook-hook and never ran. Use the real hook name, and actually install xterm-color-filter into eshell-preoutput-filter-functions (dropping eshell-handle-ansi-color) so color output is interpreted. --- modules/eshell-config.el | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/eshell-config.el b/modules/eshell-config.el index 0439a4673..d3c8ccdfd 100644 --- a/modules/eshell-config.el +++ b/modules/eshell-config.el @@ -101,7 +101,8 @@ pairs where COMMAND is the `cd' string `eshell/alias' should run." (add-hook 'eshell-mode-hook (lambda () - (add-to-list 'eshell-visual-commands '("lf" "ranger" "tail" "htop" "gotop" "mc" "ncdu" "top")) + (dolist (cmd '("lf" "ranger" "tail" "htop" "gotop" "mc" "ncdu" "top")) + (add-to-list 'eshell-visual-commands cmd)) (add-to-list 'eshell-visual-subcommands '("git" "log" "diff" "show")) (add-to-list 'eshell-visual-options '("git" "--help" "--paginate")) @@ -162,20 +163,25 @@ pairs where COMMAND is the `cd' string `eshell/alias' should run." (use-package xterm-color :after eshell + ;; Two hooks. eshell-before-prompt is the real hook name; use-package appends + ;; "-hook", so writing eshell-before-prompt-hook here registered on a + ;; nonexistent eshell-before-prompt-hook-hook and never ran. The eshell-mode + ;; hook scopes TERM=xterm-256color to eshell-spawned processes only (a global + ;; setenv would leak it to every start-process regardless of terminal). :hook - (eshell-before-prompt-hook . (lambda () - (setq xterm-color-preserve-properties t))) - ;; Scope `TERM=xterm-256color' to eshell-spawned processes only by - ;; binding the env var on the eshell mode hook. The previous global - ;; `setenv' at config-time changed `process-environment' for the - ;; whole Emacs process, so every subsequent `start-process' inherited - ;; `xterm-256color' regardless of whether the receiver was a terminal - ;; that could actually interpret the escapes. - :hook - (eshell-mode . (lambda () - (setq-local process-environment - (cons "TERM=xterm-256color" - process-environment))))) + ((eshell-before-prompt . (lambda () + (setq xterm-color-preserve-properties t))) + (eshell-mode . (lambda () + (setq-local process-environment + (cons "TERM=xterm-256color" + process-environment))))) + :config + ;; Wire xterm-color into eshell's output pipeline (per its README): install + ;; the filter and drop eshell's own ANSI handler. Without this the escapes are + ;; never interpreted and TERM=xterm-256color only leaks raw codes. + (add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter) + (setq eshell-output-filter-functions + (remove 'eshell-handle-ansi-color eshell-output-filter-functions))) (use-package eshell-syntax-highlighting :after esh-mode -- cgit v1.2.3