Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Show how different terminals show bold colors
#!/bin/sh
# Print four lines showing blocks of colors: 0-7 | 0-7bold | 8-15 | 8-15bold
perl -CADS -lwe '
my $block = shift || (chr(0x2588) x 3);
for (["", 0], ["1;", 0], ["", 8], ["1;", 8]) {
my ($bold, $offset) = @$_;
my @range = map $offset + $_, 0..7;
printf "%s %-6s ", $bold ? "bold" : "norm", "$range[0]-$range[-1]";
print map("\e[${bold}38;5;${_}m$block", @range), "\e[0m"
}
' "$@"
#!/bin/zsh
dir=$0:h
for term_array (
'st true'
'konsole true'
'gnome-terminal false'
'Terminal false'
'terminal false'
'terminator false'
'urxvt-256color true -is +is'
'uxterm true -bdc +bdc')
do
opts=( $=term_array )
term=$opts[1]
array_args=$opts[2]
opts[1,2]=()
(( $#opts )) || opts=( '' )
for opt in "${opts[@]}"
do
shcmd="echo $term $opt ; $dir/simpler ; read"
if $array_args
then
cmd=( sh -c $shcmd )
else
cmd=( "sh -c ${(q)shcmd}" )
fi
tcmd=( $term $opt -e $cmd )
$tcmd &
sleep 0.5
done
done
Owner

benizi commented Nov 30, 2012

Edited to match this SuperUser post

Owner

benizi commented Nov 30, 2012

Modified several more times to match my answer. The results in various terminals:

the results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment