Emacs,如何更改M-x shell中的一些颜色? [英] Emacs, How to change some colors in M-x shell?
问题描述
我使用Emacs 24,并希望在shell模式( ls
命令)中更改目录和文件的颜色。理想情况下 - 取决于文件的权限。
我该怎么做?
/ p>
(setq ansi-color-names-vector
[blackredgreenyellow PaleBlue洋红色青色白色))
(加钩'shell-mode-hook'ansi-color-for-comint-mode-on)
但我认为这对我来说不起作用。
我现在已经有了日光灯配色方案。但是我不想改变它的颜色,只适用于shell模式。
编辑:
当我更改我的系统终端的颜色(在我的主目录中使用.dircolrs文件) - emacs读取它,但是它(emacs)稍微改变颜色 - 它使得颜色在shell模式下变得更暗或更浅。
我不知道为什么Emacs这样做。
不同的dirs颜色(游戏,公共.. 。:
这是系统终端:
这是Emacs:
这些是更改的颜色,默认颜色和日光主题Emacs在蓝色背景上制作蓝色背景。
我明白这不是一个大问题找到一个黑客,只是想知道为什么Emacs会改变颜色。
这是我使用的为emacs设置日光颜色。我去了,发布了我的整个ansi-term配置,以防任何其他设置可能有用。
(use-package ansi- term
:defer t
:init
(progn
;;;;在当前缓冲区中使用变量宽字体face
(defun my-buffer- face-mode-variable()
;;将字体设置为当前缓冲区中的变量宽度(比例)字体
(interactive)
(setq buffer-face-mode-face' :家庭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 $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
define-key term-raw-map(kbdMx)'execute-extended-comma )
(setq autopair-dont-activate t)
(setq ac-auto-start nil)
(visual-line-mode -1)
;; (我的缓冲区面部模式变量)
))
(defun my-term-paste(& optional string)
(interactive)
process-send-string
(get-buffer-process(current-buffer))
(如果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(kbdCy)'my-term-paste)
(define-key term- raw-map(kbdsv)'my-term-pasteboard-paste)
(let((base03#002b36)
(base02#073642 )
(base01#586e75)
(base00#657b83)
(base0#839496)
(base1#93a1a1)
base2#eee8d5)
(base3#fdf6e3)
(黄色#b58900)
(橙色#cb4b16)
(红色#dc322f)
(洋红色#d33682)
(紫色#6c71c4)
(蓝色#268bd2)
(青色#2aa198)
#859900))
(setq ansi-term-color-vector
(vconcat`(未指定,base02,红,绿,黄,蓝
,品红,青色,base2))))))$)$ b $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.
How can i do this?
I tried playing with
(setq ansi-color-names-vector
["black" "red" "green" "yellow" "PaleBlue" "magenta" "cyan" "white"])
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
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.
Edit:
When I change colors for my system terminal (using .dircolrs file in my home directory) - emacs reads it, BUT it(emacs) slightly changes colors - it makes a color a bit darker or lighter in shell-mode.
And I don't know why Emacs does it.
Different dirs colors (games, Public...:
This is system terminal:
And this is Emacs:
These are changed colors, with default colors and solarized-theme Emacs made blue dirs on a blue background.
I understand that it's not a big problem to find a hack, just want to know why Emacs changes colors a bit.
解决方案 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屋!