diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-15 21:45:49 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-15 21:45:49 -0500 |
| commit | de32ffbe0d501f9dc61bc3a8889df3e207459535 (patch) | |
| tree | eed02caa56e839e0974e125f50c0b4fcf66604b8 /modules/eshell-config.el | |
| parent | 4038cf59f196616d293732525ba2c4d407a2f060 (diff) | |
| download | dotemacs-de32ffbe0d501f9dc61bc3a8889df3e207459535.tar.gz dotemacs-de32ffbe0d501f9dc61bc3a8889df3e207459535.zip | |
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.
Diffstat (limited to 'modules/eshell-config.el')
| -rw-r--r-- | modules/eshell-config.el | 34 |
1 files changed, 20 insertions, 14 deletions
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 |
