Emacs,如何在 M-x shell 中更改某些颜色? [英] Emacs, How to change some colors in M-x shell?

查看:24
本文介绍了Emacs,如何在 M-x shell 中更改某些颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Emacs 24 并且想在我处于 shell 模式(ls 命令)时更改目录和文件的颜色.理想情况下 - 取决于文件的权限.

I use Emacs 24 and want to change a color of dirs and files while I'm in shell-mode (ls command). Ideally - depending on rights of the file.

我该怎么做?

我试过玩

(setq ansi-color-names-vector
      ["black" "red" "green" "yellow" "PaleBlue" "magenta" "cyan" "white"])
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

但我认为这对我不起作用.
我现在有日晒配色方案.但我不想改变它的颜色,仅适用于 shell 模式.

But I think it doesn't work for me.
I have solarized color scheme now. But I do not want to change it's colors, only for shell-mode.


当我更改系统终端的颜色时(使用主目录中的 .dircolrs 文件) - emacs 读取它,但 it(emacs) 稍微改变颜色 - 它使 shell 模式下的颜色更深或更浅.

而且我不知道 Emacs 为什么要这样做.

And I don't know why Emacs does it.

不同的目录颜色(游戏、公共...:
这是系统终端:
这是 Emacs:

Different dirs colors (games, Public...:
This is system terminal:
And this is Emacs:

这些是更改的颜色,默认颜色和曝光主题 Emacs 在蓝色背景上制作蓝色目录.

These are changed colors, with default colors and solarized-theme Emacs made blue dirs on a blue background.

我知道找hack不是什么大问题,只是想知道为什么Emacs会稍微改变颜色.

I understand that it's not a big problem to find a hack, just want to know why Emacs changes colors a bit.

推荐答案

这是我用来为 emacs 设置 Solarized 颜色的方法.我继续发布了我的整个 ansi-term 配置,以防任何其他设置可能有用.

Here is what I use to set Solarized colors for emacs. I went ahead and posted my whole ansi-term config in case any other settings might be useful.

(use-package ansi-term
  :defer t
  :init
  (progn

    ;; ;; Use variable width font faces in current buffer
    (defun my-buffer-face-mode-variable ()
    ;;   "Set font to a variable width (proportional) fonts in current buffer"
      (interactive)
      (setq buffer-face-mode-face '(:family "Menlo For Powerline" :height 100))
      (text-scale-adjust 1)
       (buffer-face-mode))

    (setq system-uses-terminfo nil)
    (add-hook 'term-mode-hook
              '(lambda ()
                 (linum-mode 0)
                 (term-set-escape-char ?C-z)
                 (term-set-escape-char ?C-x)
                 (define-key term-raw-map "C-c" 'term-interrupt-subjob)
                 (define-key term-raw-map (kbd "M-x") 'execute-extended-command)
                 (setq autopair-dont-activate t)
                 (setq ac-auto-start nil)
                 (visual-line-mode -1)
                 ;; (my-buffer-face-mode-variable)
                 ))

    (defun my-term-paste (&optional string)
      (interactive)
      (process-send-string
       (get-buffer-process (current-buffer))
       (if string string (current-kill 0))))

    (defun my-term-pasteboard-paste ()
      (interactive)
      (process-send-string
       (get-buffer-process (current-buffer))
       (ns-get-pasteboard)))

    (add-hook 'term-exec-hook '(lambda ()
                                 (set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix)
                                 (goto-address-mode)
                                 (define-key term-raw-map (kbd "C-y") 'my-term-paste)
                                 (define-key term-raw-map (kbd "s-v") 'my-term-pasteboard-paste)
                                 (let ((base03 "#002b36")
                                       (base02 "#073642")
                                       (base01 "#586e75")
                                       (base00 "#657b83")
                                       (base0 "#839496")
                                       (base1 "#93a1a1")
                                       (base2 "#eee8d5")
                                       (base3 "#fdf6e3")
                                       (yellow "#b58900")
                                       (orange "#cb4b16")
                                       (red "#dc322f")
                                       (magenta "#d33682")
                                       (violet "#6c71c4")
                                       (blue "#268bd2")
                                       (cyan "#2aa198")
                                       (green "#859900"))
                                   (setq ansi-term-color-vector
                                         (vconcat `(unspecified ,base02 ,red ,green ,yellow ,blue
                                                                ,magenta ,cyan ,base2))))))

这篇关于Emacs,如何在 M-x shell 中更改某些颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆