Git Product home page Git Product logo

xterm-color-count's Introduction

XTerm Color Count

Count how many colors your XTerm actually supports, since it may be different from what tput colors reports.

For example, both gnome-terminal and XTerm support 256 colors, but tput colors returns 8.

Usage

./xterm-color-count.sh

You might have to wait a few seconds for the result to be returned.

./xterm-color-count.sh -v

Print each color number and show what it looks like.

./xterm-color-count.sh [number]

Show all the colors, like -v, but use a given number instead of the count.

Bugs

  • This does not work with the Linux console as it does not support the OSC 4 escape sequence. Instead the script falls back to tput colors which uses the terminfo file.

Discussion

  • It is a mystery why the default terminfo for XTerm and gnome-terminal lie about how many colors they have. You can "fix" it so tput colors returns the proper result by using export TERM=xterm-256color. Some applications (such as emacs in a terminal window) will use the extra colors. For example, try,

      TERM=xterm-256color  emacs -nw -f list-colors-display -f delete-window
    
  • A 256 color XTerm has this color mapping

    • System colors: 0 to 15
    • Grayscale: 232 to 255 (note, black and white intentionally omitted)
    • 6x6x6 color cube: 16-231 (For R,G,B between 0 and 5, color-index = 16 + R×6×6 + G×6 + B)

Credit

L0b0 wrote the code, hackerb9 changed it to a binary search. Gilles did all the research, and has awesome communication skills and *nix knowledge.

xterm-color-count's People

Contributors

l0b0 avatar hackerb9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.