permacomputing

Source repository for the main permacomputing wiki site
git clone http://git.permacomputing.net/repos/permacomputing.git # read-only access
Log | Files | Refs

commit a3c2fbacf5a5da6fb94a7705a5a0be4c56838f21
parent 88ea9d320a421464117d7774ff3b954a593855da
Author: Nick Moffitt <nick@zork.net>
Date:   Wed, 20 May 2026 09:25:14 +0100

explaining colour detection

Diffstat:
Mspacehobo.mdwn | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/spacehobo.mdwn b/spacehobo.mdwn @@ -51,4 +51,17 @@ _noop[0]='array accesses turn 0/nonzero into defined/undef!' PS1+='\$ ' ``` +### Here's how we detect colour support + +Most terminals support the standard ANSI escape sequences now, but we still have to be careful. This catches ghostty, kitty, foot, and any terminal type with `color` in the name (such as `tmux-256color` or `xterm-256color-bce`). + +``` +case "$TERM" in + *[is]tty*|foot*|*color*) color_prompt=yes;; + *) [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null && color_prompt=yes;; +esac +``` + +If it doesn't find your terminal in that list, and the system you're on has `ncurses` installed, then it will try to send a code for red text to `/dev/null` with the `tput` command, and keep you colour-free if that fails. + # I just think it's neat!