Skip to content

๐Ÿ“Ÿ Terminal color tests for POSIX shells

License

Notifications You must be signed in to change notification settings

Neved4/color.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Shell Script POSIX.1%2D2017

color.sh - Test terminal colors with POSIX shells

Original by Daniel Crisman.

Generated using agg, colors by kanagawa.nvim.

Getting Started

Prerequisites

Installation

Paste in a macOS Terminal or Linux shell prompt:

/bin/sh -c "$(curl -fsSL https://github.com/Neved4/color.sh/tree/master/install.sh"

Usage

color.sh [bg | fg | table]

Portability

Supported shells

Shell Version Supported
bash 5.2.15 Yes
dash 0.5.12 Yes
ksh93 93u+m/1.0.7 Yes
mksh 59c Yes
oksh 7.3 Yes
osh 0.18.0 Yes
posh 0.14.1 Yes1
yash 2.55 Yes
zsh 5.9 Yes
elvish 0.19.2 No
etsh 5.4.0 No
fish 3.6.1 No
tcsh 6.21.00 No
nsh 0.4.2 No
nu 0.85.05 No
ysh 0.18.0 No
xonsh 0.14.1 No

Benchmarks

Note that while scolor.sh provides a more elegant implementation, color.sh more effectively demonstrates the performance of every shell. See Benchmarks.2

Standards

This script conforms to ISO 9945:2009, also known as POSIX.1-2017.3

License

This repository is licensed under the terms of the MIT License.

See the LICENSE file for details.

Acknowledgments

Special thanks to @mirabilos for the many suggestions, corrections and feedback.

Footnotes

  1. To accomodate posh, parameter substitution had to be used. See: What does ${1+"$@"} mean | Sven Mascheck. โ†ฉ

  2. Note that pdksh derived shells, such as mksh, oksh or poskh, have a higher fork-exec penalty when using /usr/bin/printf, compared to the Korn shell built-in print. Targeted code was introduced to precisely assess performance. โ†ฉ

  3. IEEE Std 1003.1-2017: Standard for Information Technology โ€” Portable Operating System Interface (POSIXยฎ), ISO/IEC/IEEE 9945:2009/COR 2:2017. URL: https://pubs.opengroup.org/onlinepubs/9699919799/ โ†ฉ