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.
M-x customize-variable RET ansi-color-names-vector RET
Existing text will not have been affected, but newly printed text (even in the same shell buffer) will show the new colors.
Somewhere I found this, and it helped me (I'm a complete newbie, but I thought thatsetq ansi-color-names-vector
would be enough):
(setq ansi-color-names-vector
["black" "tomato" "PaleGreen2" "gold1"
"DeepSkyBlue1" "MediumOrchid1" "cyan" "white"])
(setq ansi-color-map (ansi-color-make-color-map)) ;; helped line
Now ansi-color-names-vector
works in shell.
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))))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With