colors - 外壳和颜色输出
问题描述
在使用 eshell 时,我面临一个关于 shell 输出颜色实现的奇怪行为。这是我的 .emacs 的内容:
(require 'xterm-color)
(require 'eshell)
(add-hook 'eshell-before-prompt-hook
(lambda ()
(setq xterm-color-preserve-properties t)))
(add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
(setq eshell-output-filter-functions (remove 'eshell-handle-ansi-color eshell-output-filter-functions))
(setenv "TERM" "xterm-256color")
奇怪的是,在 emacs 初始化后,eshell 无法正确显示输出(例如 git 或 pytest)的颜色。但是它不会引发任何错误,并且在它被初始化之后,我使用 Cx Ce 评估我的 init 文件的这一部分,并且在我这样做并重新启动 eshell 之后,它可以按预期正常工作。
我不明白为什么只有在初始化 emacs 之后执行它才会起作用,但不会对 .emacs 产生预期的影响。
我的 .emacs 上确实有 (setq initial-buffer-choice 'eshell) 行,但仅在上述部分之后。
关于为什么会发生这种情况的任何见解都会有所帮助。谢谢,
编辑 1
我将问题缩小到setenv
语句和initial-buffer-choice
. 出于某种原因,当我没有initial-buffer-choice
注释时,TERM
变量设置为dumb
. 另一方面,如果我initial-buffer-choice
在启动后评论并打开 eshell,那么一切都按预期工作。
我尝试将setenv
执行添加为 eshell-mode 和 emacs-startup 的钩子,以查看是否可以在启动期间强制执行它,但没有任何效果。
解决方案
推荐阅读
- python - 从具有相同名称的多个 div 的 div 中查找值
- java - 以编程方式将文件从一个容器复制到 Azure Data Lake 2 中的另一个容器
- kubernetes - Kiali 仪表板无法获取 k8 命名空间应用程序
- javascript - 在 AFrame 中随时随地操作顶点?
- java - 当我在 LINUX 计算机上运行 jenkins 自动化(带有 groovy 的 Selenium)作业时出现 geb.driver.DriverCreationException
- python - 视频分类层的 Keras 神经网络与层不兼容:预期 ndim=5,发现 ndim=4。收到的完整形状:(无、120、120、3)
- excel - 如何在 Excel 中查询字段名称可能并不总是相同的 Access 数据库
- c - ANSI 转义码 CSI 6n 总是返回 column=1
- python - 如何遍历数据框并创建列表
- javascript - 两个带有 window.onload = function() 的 JS 文件有冲突