cwonrails
11/30/2012 - 5:26 AM

Show how different terminals show bold colors

Show how different terminals show bold colors

#!/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
#!/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"
}
' "$@"