How do I set up my Linux X terminal so that Emacs has access to 256 colors?
According to this you need ncurses-term
library in addition to setting TERM
to xterm-256color
.
Okay, this has some other things to try like :
The xterm in Ubuntu Edgy does not advertise 256 color support by
default. To fix this you need to install a 256 color terminfo entry,
and tell xterm to use it:
apt-get install ncurses-term
echo XTerm.termName: xterm-256color \
>>~/.Xdefaults
xrdb -merge ~/.Xdefaults
and :
So you need a file term/screen-256color.el in your load-path. Emacs
22 expects it to contain a terminal-init-screen defun. Emacs 21
expects it to contain a bunch of top-level forms. Here's what I use:
;;; This is for GNU Emacs 22
(defun terminal-init-screen ()
"Terminal initialization function for screen."
;; Use the xterm color initialization code.
(load "term/xterm")
(xterm-register-default-colors)
(tty-set-up-initial-frame-faces))
;;; This is for GNU Emacs 21
(if (= 21 emacs-major-version)
(load "term/xterm-256color"))
For Emacs 21, you also need to install the xterm-256color.el file from
http://www.splode.com/~friedman/software/emacs-lisp/src/term/xterm-256color.el
Emacs/xterm color annoyance on Linux
The color brightwhite
looks ok on my Emacs (which is running under a terminal, not X). On RHEL5 I have my TERM
environment variable set to xterm-256color
. If it's working correctly, you should be able to run these scripts and see 256-color output. Under Emacs, you should see a reasonably smooth color ramp (no obviously duplicated colors) when you do M-x list-colors-display
. If not, you are probably missing the right termcap entry (try installing the libtermcap-devel
package, I think).
If I change TERM
to xterm-color
, then brightwhite
comes out a bit gray in the output of list-colors-display
.
I'm not sure about RHEL4.
Why is the super simple fuction not displaying 256 colors in my Mac terminal?
Try using printf
instead:
for code in {0..255}; do printf "\e[38;05;${code}m $code: Test"; done
Running GNU Screen with 256 colors on OS X Lion
By default, screen
is not aware that it is running in a 256-color-capable xterm
. To make programs in screen
recognize this feature, you need to set a couple of things in your ~/.screenrc
:
term "screen-256color"
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
If this doesn’t work for you, your version of screen
probably wasn’t compiled with ./configure --enable-colors256
. You can check this in the welcome screen when starting screen
. The default version that comes with OS X doesn’t support 256 colors. You could check out the source and compile your own version, putting the resulting binary in your $PATH
(I put it in ~/bin
which I added to my $PATH
):
git clone git://git.savannah.gnu.org/screen.git
cd screen/src
./autogen.sh
./configure --enable-colors256
make # I got a lot of warnings here, but they don't seem to matter
sudo make install
cp screen ~/bin/screen
Sources: 1 and 2
Related Topics
How to Pipe Output to a File When Running as a Systemd Service
Using the Universal Chess Interface
Difference Between .Dynamic .Dynsym and .Dynstr in an Elf Executable
Which Stack Is Used by Interrupt Handler - Linux
How to Add JSON Object to JSON File Using Shell Script
For Loop for Files in Multiple Folders - Bash Shell
How to Check a File Exists and Execute a Command If Not
Shared Library Bottleneck on Numa MAChine
Shell Script Password Security of Command-Line Parameters
How to Flush Cache of Hard-Disk and Flash-Disk (Or Filesystem) from Command Line
Source Code of Pthread Library
How to Capture Network Frames in a Kernel Module
How to Run Linux Docker Images on Windows Server 2016
How to Find Which Process Is Leaking Memory
How to Tail -F the Latest Log File with a Given Pattern
When Should the Option Remainafterexit Needs to Be Set True When Creating New Systemd Services
Systemd: Start Service at Boot Time After Network Is Really Up (For Wol Purpose)