In my .emacs
config file I have a following entry:
(custom-set-variables
(custom-set-faces
'(font-lock-comment-face ((((class color)
(min-colors 8)
(background dark))
(:foreground "red"))))))
This fixes the font color when TERM
environment variable is set to screen
, but breaks it when TERM
is set to xterm
. Is there a way to read value of TERM
variable and execute that code only if TERM
's value is screen
? I found this questin slightly helpful, but still I don't know how to read values of environment variables in elisp.
First I will answer what you asked, below I will answer the question you really should have asked ;)
I get the value of an environment variable you use the function getenv
. For example:
(getenv "TERM") -> "xterm-color"
However, this is a relatively clumsy way to check if your Emacs run in the terminal. Instead you can use the following:
(display-graphic-p &optional DISPLAY)
Return non-nil if DISPLAY is a graphic display.
Graphical displays are those which are capable of displaying several
frames and several different fonts at once. This is true for displays
that use a window system such as X, and false for text-only terminals.
DISPLAY can be a display name, a frame, or nil (meaning the selected
frame's display).
An older, deprecated, version is to check the variable window-system
.
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