【问题标题】:How to change colors in bash in ansi-term in Emacs [closed]如何在 Emacs 中的 ansi-term 中更改 bash 中的颜色 [关闭]
【发布时间】:2014-06-11 13:51:16
【问题描述】:

我已经尝试回答这个问题Emacs, How to change some colors in M-x shell?,但出现错误(当我调用 ansi-term 时)

Debugger entered--Lisp error: (error "Invalid face" unspecified)
  internal-get-lisp-face-attribute(unspecified :foreground nil)
  face-attribute(unspecified :foreground nil default)
  face-foreground(unspecified nil default)
  term-handle-colors-array(1)
  term-handle-ansi-escape(#<process *ansi-term*> 109)
  term-emulate-terminal(#<process *ansi-term*> "
\n[01;32mkuba@jcubic[00m:[01;34m~[00m$ ")
  read-event(nil nil 2)
  sit-for(2)
  execute-extended-command(nil "bash")
  call-interactively(execute-extended-command nil nil)

(我有使用 /bin/bash 调用 ansi-termbash 函数。

作者的回答并没有改变任何东西。

(defun foo ()
  (interactive)
  (setq ansi-color-names-vector
        ["black" "tomato" "PaleGreen2" "gold1"
                 "DeepSkyBlue1" "MediumOrchid1" "cyan" "white"])
  (setq ansi-color-map (ansi-color-make-color-map)))

(add-hook 'term-exec-hook 'foo)

这不会改变任何东西:

(setf (aref ansi-color-map 34) '(foreground-color . "red"))

我想要什么所以将目录颜色蓝色更改为更浅的颜色(该解决方案也可以显示如何更改所有颜色,以便其他人找到这个问题)

这是它在 xterm 中的样子:

以及它在 Emacs 中的外观(很难阅读目录)

【问题讨论】:

    标签: bash emacs elisp


    【解决方案1】:

    找到了:

    (set-face-attribute 'term-color-blue nil :foreground "red")
    

    现在我需要找到浅蓝色的名称。

    更新:刚刚发现我可以使用 xterm 中的十六进制:

    (set-face-attribute 'term-color-blue nil :foreground "#5555FF")
    (set-face-attribute 'term-color-green nil :foreground "#55FF55")
    (set-face-attribute 'term-color-red nil :foreground "#FF5555")
    (set-face-attribute 'term-color-magenta nil :foreground "#FF55FF")
    (set-face-attribute 'term-color-cyan nil :foreground "#FF55FF")
    (set-face-attribute 'term-color-yellow nil :foreground "#FFFF55")
    

    【讨论】:

    • 使用list-colors-display 选择正确的颜色。
    • @choroba 是的,我在 Emacs 手册中找到了。
    猜你喜欢
    • 1970-01-01
    • 2017-02-01
    • 2011-03-18
    • 1970-01-01
    • 2013-09-23
    • 2017-10-04
    • 2014-02-13
    • 1970-01-01
    • 2012-08-01
    相关资源
    最近更新 更多