256-color xterm(1)s Most Linux terminals such as xterm(1) can support at least 256 colors, but this is rarely the default set-up for users of commands such as vim(1), and ncurses(3c)-based or terminfo(1) based programs such as screen(1), wc(1) w3m(1), lynx(1), .... Typically, you can only access eight pre-defined colors easily. First, enter $ tput colors # sh/bash/ksh/pdksh/ash/zsh... users $ echo $TERM or % tput colors # csh/tcsh,,, users % echo $term This tells how many colors are supported in the terminal description (ie. your terminfo(5)/termcap(5) description) you are using. If it is at least 256 you are probably set up properly to use a substantial number of colors. If you got 8 or less from the tput(1) command, this does not always mean your terminal cannot support 256 colors. If may just mean you are using a description of your device that is ignoring the additional color capabilities. If you are not sure, read the man(1)/info(1) documentation for your terminal emulator, or your terminal manual if it is available. This condition (only seeing eight or less colors when many more are supported in hardware) may exist only because a terminal programming library such as ncurses(3c) needs to know specifics about how to access your terminals' capabilities (such as blinking, color support, underlining, reverse-video, ...). This description is conservative in many cases. But there are often alternative descriptions that you can use. The first thing to do is make sure you have a 256-color terminfo(5) file for your terminal. Typically, you can find if one is available using $ find /lib/terminfo /usr/share/terminfo -name "$TERM*256*" If nothing shows try $ find /lib/terminfo /usr/share/terminfo -name "*256*" Hopefully, the file "$TERM-256color" or something like it is found. If not, you may have to modify, install or create a terminfo(5) description, but almost all terminal emulators found on GNU/Linux and Unix machines support 256 or more colors; so at most you may have to update your terminfo files (Actually making or modifying a terminal description is beyond the intent of the information presented here). For example, in Ubuntu, you might have to enter: $ sudo aptitude install ncurses-term to get the 256-color terminfo files, assuming you are Internet-connected. For a simple test just enter $ export TERM="NNNNN" where NNNNN is the name you found, such as "xterm-256color". Concentrating on xterm(1) ... The most commonly used terminal emulator is xterm(1) or an xterm-compatible program. We will concentrate on xterm(1). To make a permanent change to your defaults edit ~/.Xdefaults and add *customization: -color XTerm*termName: xterm-256color This will not take effect until your X11 client is restarted. So enter $ xrdb -merge ~/.Xdefaults to make all NEW xterm(1)'s set up properly. Alternatively you can enter: $ xrdb -merge <<\EOF *customization: -color XTerm*termName: xterm-256color EOF To make all NEW xterm(1)'s during THIS X11 session set up. Or to just test it launch an xterm(1) with xterm -color & and then set the environment variable TERM to "xterm-256color" when the window starts. $ export TERM=xterm-256color or % set term=xterm-256color If the changes to .Xresources do not seem to work but it does if you run the xrdb(1) command, you need to add the following to your ~/.xesssion file: if [ -f $HOME/.Xdefaults ]; then xrdb -merge $HOME/.Xdefaults fi If this has been successful, if you enter $ echo $TERM you should see xterm-256color and tput color should show "256". Individual applications may need additional configuration as well. In vim(1) :set t_Co should report that you have 256 colors available. The color schemes available for vim(1) vary. Something like: $ ls /usr/share/vim/vim*/colors should produce a list like /usr/share/vim/vim*/colors/blue.vim /usr/share/vim/vim*/colors/darkblue.vim /usr/share/vim/vim*/colors/default.vim /usr/share/vim/vim*/colors/delek.vim /usr/share/vim/vim*/colors/desert.vim /usr/share/vim/vim*/colors/elflord.vim /usr/share/vim/vim*/colors/evening.vim /usr/share/vim/vim*/colors/koehler.vim /usr/share/vim/vim*/colors/morning.vim /usr/share/vim/vim*/colors/murphy.vim /usr/share/vim/vim*/colors/pablo.vim /usr/share/vim/vim*/colors/peachpuff.vim /usr/share/vim/vim*/colors/ron.vim /usr/share/vim/vim*/colors/shine.vim /usr/share/vim/vim*/colors/slate.vim /usr/share/vim/vim*/colors/torte.vim /usr/share/vim/vim*/colors/zellner.vim To try one enter something like :set syntax=on :colo desert This is really only useful with syntax highlighting on when editing file types like *.c, *.py, *.f90, ... that have color syntax set up. An example ~/.vimrc change to make is to add something like " ======================================================== " If have 256 color use colorscheme 'inkpot' " " if running in GUI mode or have colors turn coloring on if &t_Co > 2 || has("gui_running") syntax on endif " decent scheme with eight colors colorscheme desert " but if have the colors use inkpot if &t_Co == 256 colorscheme inkpot endif " ======================================================== GNU screen If screen(1) does not work with 256 colors, try this: Add the following to your ~/.screenrc file: # 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" # set TERM term screen-256color-bce If you don't use escape sequences to control your xterm(1) window size, font, position, and colors you can ignore a (current) major complication. These directions so far let any user use 256 colors but MAY DISABLE OTHER FEATURES. Test to see if this is the case. If so, here comes the worst part --- (and this is a complicated story I am not going to explain) to successfully use more colors and at the same time use commands to change font size, change window size, and so on you really need (currently) to make your own xterm(1) definition (AND CALL IT BY THAT NAME). If you are the administrator you can update the terminal definition easily by placing the terminal description at the end of this discussion in a file called "xterm.tic" and then enter: tic xterm.tic If not, you can do the same as a user -- put the tic(1) output into a file you own and set environment variables to read your own terminfo file (see "man tic(1)") . But more simply, you might want to change $TERM to "xterm" to execute the commands that change the xterm(1) and then change back again; or make a wrapper around commands you want the 256 colors for. For example: #!/bin/bash # script called "vin" for "new vi" # @(#) open vim(1) using many new options (compared to vi(1)) in current terminal window with 256 colors in xterm(1) case "$TERM") in xterm*) # if using any xterm(1) variants switch to a terminfo(1) definition that uses 256 colors TERM=xterm-256colors vim -N -u $BASE/vimrc \ -c ':highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE' \ -c "colorscheme inkpot" $* ;; *) vim -N -u $BASE/vimrc \ -c ':highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE' \ "$@" ;; esac exit 256-color terminfo entry for xterm(1) for use with tic(1)/infocmp(1) : xterm|xterm terminal emulator (X Window System) with 256 colors, am, bce, ccc, km, mc5i, mir, msgr, npc, xenl, colors#256, cols#80, it#8, lines#24, pairs#32767, initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=^J, indn=\E[%p1%dS, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~, kpp=\E[5~, kri=\E[1;2A, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smm=\E[?1034h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd, Hopefully, now that platforms with only a few colors are so rare cognoscenti will start updating the defaults to expect at least 256 colors and the defaults will work as-is. In the mean time this information should help. <xmp> </body> </html>