TERMCOLOURS(1)

๐Ÿ“ฆ
version 0.7.0 ยท 4 versions
, in epel 9

๐Ÿ’– TERMCOLOURS(1) ๐Ÿ’–

okay so bestie, this is a User Contributed Perl Documentation page and it's genuinely one of the most satisfying little tools ever โ€” let's get into it โœจ


๐ŸŒˆ NAME ๐ŸŒˆ

termcolours โ€” automatically set unique terminal colour schemes ๐ŸŽจ (yes, "colour" with a u, she's fancy)


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

termcolours [--osc] [-P|-p] [-B|-b] [-D|-L] [-n] [-v] [hostname]

termcolours --xrdb [-P|-p] [-B|-b] [-D|-L] [-n] [-v] hostname ...; alias
xterm="xterm -name xterm-`hostname`"

๐ŸŒธ DESCRIPTION ๐ŸŒธ

So the whole vibe here: your terminals each get a persistent unique background colour, generated from the hostname (or literally any other string you feel like throwing at it, no judgement ๐Ÿ’…). Then it sets the sixteen ANSI colours to contrast with that background, using shades from the Tango palette. It's giving "every window has main character energy" and honestly? Obsessed. ๐Ÿซถ


โœจ OPTIONS โœจ

  • hostname โ€” the terminal background colour gets set based on a hash of the hostname string, landing somewhere between 0x000000 (black) and 0x404040 (dark), or 0xc0c0c0 (light) and 0xffffff (white). Foreground colours are picked to contrast with the background. If you don't specify one, it defaults to the current system hostname. ๐Ÿ’ซ
  • --dry-run, -n โ€” don't actually change the terminal colour. Just, like, think about it. ๐Ÿ™ˆ
  • --palette, -p / --no-palette, -P โ€” set (or don't set) the palette of 16 ANSI colours. The default is to set them. ๐ŸŽ€
  • --background, --bg, -b / --no-background, --no-bg, -B โ€” set (or don't set) the background colour and the contrasting foreground colour. The default is to set them. ๐ŸŒท
  • --is-dark, -D โ€” exit 1 if the terminal is set to having a light background. ๐Ÿ’€
  • --is-light, -L โ€” exit 1 if the terminal is set to having a dark background. ๐Ÿ’€
  • --osc โ€” set the colour scheme for the current terminal by sending it control sequences. This is the default behaviour, so it's kind of the moment. โœจ
  • --xrdb, -x โ€” set the colour scheme for xterms started in the future ๐Ÿ”ฎ, via X11 resources of the form XTerm-{argument}*vt100*foreground and XTerm-{argument}*vt100*background.

You gotta tell xterm which resource to look at, with something like:

xterm -name "xterm-$HOSTNAME"
  • --verbose, -v โ€” be more chatty. she talks more. ๐Ÿ—ฃ๏ธ
  • --help, -h โ€” displays brief help.
  • --man โ€” displays the full manual. (hi, you're here ๐Ÿ‘‹)

๐Ÿงš EXAMPLES ๐Ÿงš

๐ŸŽจ Set the prompt colour depending on the terminal colour

Add something like the following to your ~/.bash_profile:

if termcolours --is-dark; then
    prompt_colour='37;40'
else
    prompt_colour='30;47'
fi
PS1="\[\033[0;${prompt_colour}m\]\h:\W\\$\[\033[0m\] "

For a list of potential colour codes you could use here, see the Wikipedia page ANSI escape code <https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit>. ๐Ÿ‘‘

๐Ÿณ Set the background colour for a container, without having to install termcolours inside the container

Add the following to your ~/.bashrc:

function docker {
    __termcolours_then_container "$FUNCNAME" "$@"
}
function podman {
    __termcolours_then_container "$FUNCNAME" "$@"
}
function __termcolours_then_container {
    declare -a args=("$@")

    if [[ "${args[1]}" == 'exec' || "${args[1]}" == 'run' ]]; then
        local arg
        local rc

        shift 2
        for arg in "$@"; do
            if [[ "$arg" != -* ]]; then
               termcolours "$arg"
               break
            fi
        done
    fi

    command "${args[@]}"
    rc=$?

    if [[ "${args[1]}" == 'exec' || "${args[1]}" == 'run' ]]; then
        termcolours
    fi

    return $rc
}

๐Ÿ’œ COMPATIBILITY ๐Ÿ’œ

The following terminal emulators are known to work. (vibe check: passed โœ…)

๐Ÿ–ฅ๏ธ Using OSC escape sequences

Full support ๐ŸŒŸ

Partial support ๐ŸŒ—

๐ŸชŸ Using X11 resources

  • XTerm (any version) ๐Ÿ†

๐Ÿ”— SEE ALSO ๐Ÿ”—


๐Ÿซถ AUTHOR ๐Ÿซถ

Peter Oliver <mailto:terminalcolours@mavit.org.uk> โ€” icon, legend, the moment ๐Ÿ’…


๐Ÿ“œ LICENCE ๐Ÿ“œ

Copyright 2008, 2017, 2024-2025 Peter Oliver.

This program is part of termcolours.

termcolours is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

termcolours is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. (fr fr, no cap, that's the legal vibe ๐Ÿ’€)

You should have received a copy of the GNU General Public License along with termcolours. If not, see <https://www.gnu.org/licenses/>.


๐Ÿ’– and that's the whole page bestie! this one came from perl v5.32.1, dated 2025-11-13 โ€” go forth and colour your terminals, you absolute icon ๐ŸŽ€โœจ๐ŸŒธ
๐Ÿ“ฆ where this page comes from