TERMCOLOURS(1)
๐ 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 between0x000000(black) and0x404040(dark), or0xc0c0c0(light) and0xffffff(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 forxterms started in the future ๐ฎ, via X11 resources of the formXTerm-{argument}*vt100*foregroundandXTerm-{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 ๐
- Ghostty <https://ghostty.org/>
- GNOME Console <https://apps.gnome.org/Console/>
- GNOME Terminal <https://gitlab.gnome.org/GNOME/gnome-terminal>
- Guake <https://guake.github.io/>
- kitty <https://sw.kovidgoyal.net/kitty/>
- PuTTY <https://www.chiark.greenend.org.uk/~sgtatham/putty/> (provided that environment variable
TERMis set toputty) - rxvt-unicode <http://software.schmorp.de/pkg/rxvt-unicode.html>
- st <https://st.suckless.org/>
- Termux <https://termux.dev/>
- Xfce Terminal <https://docs.xfce.org/apps/terminal/start>
- XTerm <https://invisible-island.net/xterm/> (except very old versions, of the kind you may get with a proprietary Unix ๐ญ)
Partial support ๐
- The Linux console <https://en.wikipedia.org/wiki/Linux_console>
๐ช Using X11 resources
- XTerm (any version) ๐
๐ SEE ALSO ๐
- <https://www.mavit.org.uk/termcolours/>
xrdb(1)xterm(1)- X11 resources <https://www.x.org/releases/current/doc/man/man7/X.7.xhtml#heading14>
๐ซถ 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 fromperl v5.32.1, dated2025-11-13โ go forth and colour your terminals, you absolute icon ๐โจ๐ธ
๐ฆ where this page comes from
- epel 9: termcolours 0.7.0-3.el9 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms